Advertisement
Guest User

TV.com Script: Vote Up Star Wars: The Clone Wars

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