Advertisement
someone_

TVcom_poll_rig.user.js

Dec 7th, 2012
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name TVGuideRig
  3. // @namespace tvrig
  4. // @include http://www.tv.com/lists/SpecialFeatures:list:best-animated-series/widget/poll/*
  5. // @version 2.0
  6. // ==/UserScript==
  7.  
  8. (function(){
  9.     var d = document, w = window,
  10.         getQueryVariable = function(variable) {
  11.             var query = w.location.search.substring(1), vars = query.split("&");
  12.             for (var i=0;i<vars.length;i++) {
  13.                 var pair = vars[i].split("=");
  14.                 if (pair[0] == variable) {
  15.                     return pair[1];
  16.                 }
  17.             }
  18.         }, spamVotes, spamID,
  19.         //default speed is 1 second between votes
  20.         speed = 1000;
  21.  
  22.     if( w.location.search.indexOf('speed=') == -1 ) {
  23.         speed = parseInt(prompt("Confirm this dialog to start script\n\nHow fast should this autism fest run at?\n(Lower is faster)", speed));
  24.         w.location.href = w.location.href + '?speed=' + speed;
  25.     } else {
  26.         speed = parseInt(getQueryVariable('speed'));
  27.         speed = !speed ? 1000 : speed < 100 ? 100 : speed > 100000 ? 100000 : speed;
  28.         w.count = 0;
  29.  
  30.         spamVotes = function(){
  31.             var t = [].slice.call(d.getElementsByClassName("title"))[9], x = new XMLHttpRequest(),
  32.                 msg = {"vote_rate_limit": "3",
  33.                         'list_id': 'SpecialFeatures:list:best-animated-series',
  34.                         'id': 's:79180',
  35.                         'a': 'a',
  36.                         'v': '+1'},
  37.                 string = "inp=" + encodeURIComponent(JSON.stringify(msg)) + "&csrfmiddlewaretoken=" + (document.cookie.match(/csrftoken=[^;]*/i)[0].split("=")[1] || "");
  38.             x.open('POST','/lists/update/',true);
  39.             x.setRequestHeader('Content-type','application/json; charset=utf-8');
  40.             x.setRequestHeader("Content-length", string.length);
  41.             x.setRequestHeader("Connection", "close");
  42.             x.onreadystatechange = function(){
  43.                 if(x.readyState == 4) {
  44.                     if(x.status != 200 && x.status != 304) {
  45.                         clearInterval(spamID);
  46.                         setTimeout(function(){spamID = w.setInterval(spamVotes, speed)}, 20000);
  47.                     }
  48.                 }
  49.             };
  50.             x.send( string );
  51.             if( t ) {
  52.                 t.innerHTML = t.innerHTML.substring(0, t.innerHTML.lastIndexOf('>') + 1) + "Counter: "+ w.count++;
  53.             }
  54.         };
  55.         spamID = w.setInterval(spamVotes, speed);
  56.         spamVotes();
  57.     }
  58. }())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement