Showing posts with label Web. Show all posts
Showing posts with label Web. Show all posts

Friday, December 21, 2012

Automated ClixGrid clicking


If you are reading this, you probably know what ClixSense is and it's game - ClixGrid. If you do not know - check it out. Here I'll show you how to automate the clicking on the game (ClixGrid) - there is no captcha here, so you can easily do that with a bit of programming. I made a script in my spare time, so you won't have to program.

Here is a video of how the script is working:



WARNING! USE AT YOUR OWN RISK! I'M NOT RESPONSIBLE IF YOU GET YOUR ACCOUNT SUSPENDED!

Current Version: 20161023 (Changelog below)

How it works:

I use Selenium tests to mimic human actions. All the actions are applied without using the cursor, so you can use your mouse wherever you want - the clicks will still happen on the right places. The script generates random numbers to target the box it'll click. If the box is clicked, the script generates another set of numbers. If not - it clicks it, waits for the ad to complete and closes the popup. Then if there are tries left, it generates numbers again. Selenium doesn't solve the focus problem, though. Using only this script, you will automate the clicking, but you won't be able to use your PC, as you'll loose focus of the advertisements window, which will stop the timer. To solve this, I used a virtual machine - it has it's own focus, so I can use my primary OS as usual :) Because Clixsense can change the elements on the page, the script can stop working. I've included update feature to the script - after all clicking is done, the script opens this blog post, checks for newer version and alerts the user if one is available. It's good to be always up to date, to ensure the right working.

What you'll need:


1. My script.
2. Mozilla Firefox.
3. Selenium IDE addon.
4. Selenium IDE Flow Control extension.
5. (optional, but recommended) VirtualBox or any other virtual machine software.

How to install:

1. (optional) Install VirtualBox.
2. (optional) Install you OS of choice.
3. Install Firefox.
4. Install Selenium IDE addon.
5. Install Selenium IDE Flow Control extension.

How to update:

Just copy the new script over the old one and reload it, if you have loaded it into Selenium.

How to use:

1. Open Firefox.
2. Go to GlixGrid's page.
3. Open Selenium IDE (Ctrl+Alt+S).
4. Open my script from File -> Open (or press Ctrl+O).
5. On ClixGrid's board click on any box, watch the advertisement and close the window. If Firefox blocks the popup, allow all popups from clixsense.com and then continue with the instructions.
6. After one successful click on the grid, the script is ready to be run. Click on one of the play buttons you see on Selenium IDE and the clicking begins :) Watch the first one, just to be sure it's working. Sometimes, on start, Selenium IDE steals the focus from the popup, which stops the counter and the ad never completes, so be sure you watch the first ad and then you can go somewhere till this is done. If you are running the script in a virtual machine, then you can use your host OS as usual, because the script is running in the guest OS, which have it's own focus, so the windows are always focused, no matter the focused window on the host OS ;) This way you get a complete automation without having to watch the ads!

Changelog:
21122012: initial release

22122012:
- Added pause of 1s before clicking on close link. Till now, the period was a random number between 0 and 2s, but when the number was too low, "Stay on this page" dialog appeared, which brakes the script. Now the number is between 1 and 3s, so the problem should be solved.
- Now after version update check, if there is no newer version, the script redirects you to the GlixGrid page, to see your results of the clicking.
- Added check for remaining clicks at the beginning of the script. That way if you run the script for the second time, it won't fail, instead it'll go straight to checking for newer version.
- Removed useless echo command.

20121224:
- Removed onbeforeunload event from the popup. The fix in the previous version helped, but did not solved the problem entirely. Removing onbeforeunload event prevents "Stay on this page" dialog from ever appearing. In general, the dialog appears when you try to close the popup before he successfully reported to the parent site about the completion of the ad. So if there is no dialog to prevent this, the ad won't be counted, which is bad, but the script won't be broken, so he'll run the ad again, till it's counted.
- Fixed version numbering.

20161023:
- Fixed the script as it was not running at all (the id of the Close link in the popup was changed).

Wednesday, August 8, 2012

DBSyncer - A tool to synchronize databases through repository


Recently I started cleaning my PC from old, useless code and projects that I had been working on in the past and then I came across DBSyncer - a project intended to sync databases through repositories. Pretty useful if you and your colleagues (or friends) are developing a website or system, and you need a tool to sync the database between all the dev computers. I started developing this project in my spare time back in the beginning of 2011 because I needed such tool at work, where we were constantly  fighting with database synchronization through our subversion. But then in May 2011 I found a better job, where I didn't need this tool anymore, so development halted. Still, the made progress is pretty good - DBSyncer is fully working. I never released it because I wanted to implement a couple of features to it, but never got the time. Now, after more than an year, I'll release it as is - I'm sure there will be people happy to use it. I only replaced deprecated functions in newer PHP versions with working ones. So, what DBSyncer offers?

  • Automated database synchronization
  • Database change revisions
  • Database revert to revision
  • Well documented API
  • GUI

The main part of DBSyncer is it's PHP class - DBSyncer.php (only about 33kb). All other files are optional. If you choose to use only this file, you'll have to make the settings manually. Info about this, how to use DBsyncer and what methods it offers, is provided in the docs. If you want to use the GUI, then you'll need all files from the archive (available to download at project's page in Google Code). GUI can help you with the following things:

  • Install DBSync
  • Add new database
  • Import database
  • Remove database
  • See revision changes for each database
  • Apply revision to database both forward and backwards
  • Add or remove revisions
  • Export database without data (structure only)
  • Make changes to the config

All of these things are provided by DBSyncer.php. The GUI only helps you to manage databases visually. Also note GUI won't sync your databases automatically. If you want that, then you'll need to implement DBSyncer.php in your project and use its methods. See docs for more info.

Main screen
Screen showing database revisions

There is some unfinished work with the GUI - no "please wait" screen when applying revision (probably somewhere else too). If I have time, I'll fix this.

Final words - Although not entirely finnished, DBSyncer is still a good piece of work if it fits your needs. Enjoy!

Monday, May 28, 2012

Automated JS/CSS combining/minifying system - JSS Build Environment


Recently I wrote a post about JS compressors and how they compare to each other. Now I've build a system for combining and/or minifying JS and CSS files. This system uses Google's Closure Compiler for JS minification and Google's Closure Stylesheets for CSS minification. Both of them require Java, so if you want to use 'Compress' option, then you'll need to install it and point JSS Build Environment to java.exe. I recommend extracting jPortable to a folder next to this EXE file.


Features:



- JavaScript combine and minify
- CSS combine and minify
- Automatic combine/minify when one of the input files is changed.
- Control over the sequence of combining
- Minimizing to system tray
- Single EXE without installer


Setup:



close-compiler is the folder containing compiler.jar file of Closure Compiler.
closure-stylesheets is the folder containing closure-stylesheets.jar of Closure Stylesheets.
Java folder contains extracted files from jPortable.
JSS Build Environment can run without all of these folders, but you'll only have combine option.

Usage:


To use this app, you need to add files to CSS or JS panels (or both), choose Output file and click Build. It's as simple as that. Of course this only activates combining. No compression is applied. If you want compression, then you have to setup files as described in Setup above and then check Compress checkbox before building.
Now let's talk about Auto Build feature. This is really useful feature when you need to build every time you change something. Auto Build monitors the files and when some file is changed it starts build procedure. Build procedure includes compression if it's checked, but I recommend not checking it, as compression takes time and you'll need to wait a lot just to see let's say your text in red. Combining Auto Build with minimizing to system tray and some balloons makes things look and work really good.


Download:


JSS Build Environment
Source Code (in Delphi XE)

Happy codding ;)

Monday, May 7, 2012

Converting multiple files into WebP under Windows (MultiWebP)

You know of Google's image format WebP? If you do and you want to convert your images to .webp, you'll notice it's a bit hard, as you have to do it image by image. I wrote a little batch file, called MultiWebP, which can automate this for you ;) You can download it bellow. There are two files - test.bat and encode.bat. The first is optional and is used to encode only one file, just to test the settings. The second file is used to encode the whole folder :)

Update: New version is out!
Details for MultiWebP 2.0:
- Only one file! test.bat and encode.bat are now combined in MultiWebP.bat.
- One file means only one line of settings, not two as before.
- Subfolders. MultiWebP now supports subfolders. You can run it on a parent folder and all files will be encoded, even those in subfolders.
- Progress. MultiWebP now shows total files to convert and files converted till now.
- Colors. MultiWebP now shows it's window in different colors, depending on the progress made. This is useful for remote observing (if you lay down on your bed and wait it to finish). Color levels: black - 0 to 32%, blue - 33 to 66%, aqua 67 to 100% and green when all is done.
- Beep. Additionally Windows' beep sound is heard upon all task completed.

Installation:
1. Download WebP package from Google and extract it somewhere. Optional you can download WebP codec to be able to open .webp files with your Windows Photo Viewer.
2. Download my scripts and extract them.
3. Place the two files next to cwebp.exe.

4. Create two shortcuts for test.bat and encode.bat and name them as you like.

5. Open Explorer and type in the address bar %APPDATA%\Microsoft\Windows\SendTo
6. Paste the two shortcuts there. Now you should see both of them in the Send To menu.

Settings:
You should read Readme.txt of WebP and learn about what cwebp.exe parameters are available. Then you should open test.bat/encode.bat, find cwebp.exe and change it's parameters. I've included some by default, so you can start using my scripts without changing settings.

Usage:
1. Create a folder where you'll put cwebp.exe supported images that have common source (shot with the same camera), to ensure settings will be the same for all files.
2. Right click one of the files and send it to test.bat.

3. Change settings for test.bat if you don't like the result and repeat step 2, until you are pleased with the result.
4. After you found your settings, copy them to encode.bat.
6. You are about to convert the whole folder, so make sure you don't have any unsupported by cwebp.exe files as they will be deleted in the end!
7. Right click on the folder and send it to encode.bat.

8. Go take a walk :)

Wednesday, May 2, 2012

JavaScript Compressors Comparison

Recently I got back a bit to my old hobby - writing JS in my spare time. There is something in me that makes me optimize things. I love optimizing, no matter if it'll be a drop in the ocean, a lost time. But no matter how much you optimize, you never can beat a JavaScript compressor. So, I decided to test a couple of JS compressors available for free online use and see which is the best. For this purpose I used two files, from some of my JS projects:

JSOS.js - 97.8 KB (100 227 bytes) of mainly procedure oriented code, written for my JavaScript Operating System 5 years back. The code is a crap. Not one standard is kept while writing. Hell, I didn't even knew there are standards back then. And I didn't knew about compressors neither, so I compressed as much as I could by hand.
portfolio.js - 45.9 KB (47 020 bytes) of mainly object oriented code, written for my portfolio. Code is a bit new (one year old or so), but I still don't like it :D

The compressors I choose to benchmark are:

1. Google's Closure Compiler
2. Yahoo's YUI Compressor
3. Microsoft's Ajax Minifier
4. Dojo's shrinksafe
5. Online Javascript Compression Tool

Ok, lets see how they do on default settings.

1. Closure Compiler
JSOS.js - 88.1 KB (90 220 bytes)
portfolio.js - 39.4 KB (40 374 bytes)
2. YUI Compressor
JSOS.js - 89.8 KB (92 035 bytes)
portfolio.js - 34.5 KB (35 406 bytes)
3. Ajax Minifier
JSOS.js - 88.4 KB (90 537 bytes)
portfolio.js - 33.9 KB (34 734 bytes)
4. shrinksafe
JSOS.js - 93.6 KB (95 885 bytes)
portfolio.js - 36.8 KB (37 767 bytes)
5. Online Javascript Compression Tool
JSOS.js - 89.2 KB (91 358 bytes)
portfolio.js - 34.5 KB (35 381 bytes)

Let's wrap-up these results in graphics:
Or in percents:
As we can see, the "default" winner for crappy procedure oriented code is Google's Closure Compiler with just 317 bytes ahead of Microsoft's Ajax Minifier. For object oriented crappy code, the "default" winner this time is Microsoft's Ajax Minifier, while previous winner, Google's Closure Compiler is at last place.
Now let's see what those compressors can do at their best:


1. Closure Compiler
JSOS.js - 35.5 KB (36 376 bytes)
portfolio.js - 31.5 KB (32 352 bytes)
2. YUI Compressor
JSOS.js - 89.8 KB (92 035 bytes)
portfolio.js - 34.5 KB (35 406 bytes)
3. Ajax Minifier
JSOS.js - 84.7 KB (86 767 bytes)
portfolio.js - 33.2 KB (34 056 bytes)
4. shrinksafe
JSOS.js - 92.3 KB (94 562 bytes)
portfolio.js - 36.1 KB (36 991 bytes)
5. Online Javascript Compression Tool
JSOS.js - 89.2 KB (91 358 bytes)
portfolio.js - 34.5 KB (35 381 bytes)

In graphics:
and in percents:
Yes, I noticed Closure Compiler, too! At first I thought it produced a non working code, but when I tried it - it works as a charm! I don't know how they did it, but they did it :) So apparently the "max" winner for crappy procedure oriented code is Google's Closure Compiler. For crappy object oriented code, the "max" winner is again Google's Closure Compiler with a lead of more that 1k of code. Notice Yahoo's YUI Compressor and Online Javascript Compression Tool - they both have the same numbers as for default test?!?!? Well, their default settings are actually their best settings. That's a bit disappointing, as default settings of some compressors are better that the best settings of YUI Compressor, and I know a lot of people are using it. So I recommend to those people to switch to Closure Compiler.

Let's make an average to name a winner by the normal formula:
1st place = 5 points
2nd place = 4 points
3rd place = 3 points
4th place = 2 points
5th place = 1 point
Results:

Closure Compiler YUI Compressor Ajax Minifier shrinksafe OJSCT
Points 16 10 17 5 13
So the order is:
1. Ajax Minifier
2. Closure Compiler
3. Online Javascript Compression Tool
4. YUI Compressor
5. shrinksafe
You agree with that? Neither do I. This formula is good for other uses. Here we should really find how many bytes are saved, average. Let's see the same table again, but this time with bytes and percents saved.

Closure Compiler YUI Compressor Ajax Minifier shrinksafe OJSCT
Bytes 95172 39612 48400 29289 41016
Percents 32.32 13.45 16.43 9.95 13.93
Now we see who the real winner is:
1. Closure Compiler
2. Ajax Minifier
3. Online Javascript Compression Tool
4. YUI Compressor
5. shrinksafe

So next time you need to shrink JS files, consider Closure Compiler as a good choice :)