Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Auto vote for CSC
- // @namespace http://casinocoin.org/
- // @version 0.1
- // @description Auto votig for casinocoin on swisscx
- // @match https://www.swisscex.com/voting
- // @copyright 2014+, JohnnyM, Licence: WTFPL (http://www.wtfpl.net/txt/copying/)
- // ==/UserScript==
- // @include https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js
- var cscButton = null;
- var clickCount = 0;
- function getRandomInt(min, max) {
- return Math.floor(Math.random() * (max - min + 1)) + min;
- }
- function clickVote() {
- if (cscButton.is(':disabled')) {
- console.log('Button disabled. Reload in 5 sec.');
- setTimeout(function(){ window.location.reload(true); }, 1000*5);
- return;
- }
- cscButton.click();
- clickCount++;
- console.log('Clicks: '+ clickCount);
- return;
- }
- function doVote() {
- var csctd = $("tr td:contains('CasinoCoin')");
- if (csctd.length !== 1) {
- console.log('Error: More then 1 or no csc rows in voting table!');
- setTimeout(function(){ window.location.reload(true) }, 5000);
- return;
- }
- console.log('Got CSC td');
- var button = $(csctd[0]).parent().find('button')[0];
- //console.log(button);
- if (button.disabled === true) {
- console.log('Button is disabled');
- var timer = $('p[data-ng-hide="canVote"] > strong');
- if (timer.length === 1) {
- console.log('Found timer');
- // refresh each 10 min to stay logged in
- var reload = ['00:00:01', '00:10:00', '00:20:00', '00:30:00', '00:40:00', '00:50:00', '23:59:45'];
- var left;
- timer.on('DOMSubtreeModified', function() {
- left = timer.html();
- if (reload.indexOf(left) !== -1) {
- window.location.reload(true);
- }
- });
- } else {
- var timeout = getRandomInt(30, 60);
- console.log('Can\'t find timer. Refresh in '+ timeout + ' seconds');
- setTimeout(function(){ window.location.reload(true) }, 1000*timeout);
- }
- return;
- }
- console.log('Button is enabled. Clicking');
- cscButton = $(button);
- clickVote();
- setTimeout(function(){ clickVote(); }, 1000*3);
- setTimeout(function(){ clickVote(); }, 1000*6);
- }
- $(document).ready(function() {
- console.log('doc ready');
- setTimeout(function() { doVote(); }, 1000);
- //$('p[data-ng-hide="canVote"] > strong').html(); // time to next vote
- //$('p[data-ng-hide="canVote"]').prev().find('strong').html(); // votes left
- // connection issues? refresh page after 15 min.
- setTimeout(function() { window.location.reload(true); }, 1000*60*15);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement