PTH Change default request vote amount

Set the default request vote amount when clicking the [+] vote

  1. // ==UserScript==
  2. // @name PTH Change default request vote amount
  3. // @version 0.4
  4. // @description Set the default request vote amount when clicking the [+] vote
  5. // @author Chameleon
  6. // @include http*://redacted.ch/*
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/87476
  9. // ==/UserScript==
  10.  
  11. var amount = 1024; // In MB
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. amount=amount*(1024*1024);
  17. var as=document.getElementsByTagName('a');
  18. for(var i=0; i<as.length; i++)
  19. {
  20. var a=as[i];
  21. if(a.href.indexOf('javascript:Vote') == -1)
  22. continue;
  23. a.href = a.href.replace(/Vote\(0/, 'Vote('+amount);
  24. }
  25. var span=document.createElement('span');
  26. span.setAttribute('id', 'current_uploaded');
  27. document.body.appendChild(span);
  28. span.style.display='none';
  29. var upAmount=unPretty(document.getElementById('stats_seeding').getElementsByTagName('span')[0].textContent);
  30. span.innerHTML = upAmount;
  31. var span=document.createElement('span');
  32. span.setAttribute('id', 'current_downloaded');
  33. document.body.appendChild(span);
  34. span.style.display='none';
  35. var downAmount=unPretty(document.getElementById('stats_leeching').getElementsByTagName('span')[0].textContent);
  36. span.innerHTML = downAmount;
  37. var span=document.createElement('span');
  38. span.setAttribute('id', 'current_rr');
  39. document.body.appendChild(span);
  40. span.style.display='none';
  41. var requiredRatio=document.getElementById('stats_required').getElementsByTagName('span')[0].textContent;
  42. span.innerHTML = requiredRatio;
  43. })();
  44.  
  45. function unPretty(size)
  46. {
  47. var s=parseFloat(size);
  48. if(size.indexOf('KB') != -1)
  49. s = s*Math.pow(2, 10);
  50. else if(size.indexOf('MB') != -1)
  51. s = s*Math.pow(2, 20);
  52. else if(size.indexOf('GB') != -1)
  53. s = s*Math.pow(2, 30);
  54. else if(size.indexOf('TB') != -1)
  55. s = s*Math.pow(2, 40);
  56. else if(size.indexOf('PB') != -1)
  57. s = s*Math.pow(2, 50);
  58.  
  59. return Math.round(s);
  60. }