WWT - Auto Reload with counter

Reload pages every x minutes

  1. // ==UserScript==
  2. // @name WWT - Auto Reload with counter
  3. // @namespace Keka_Umans
  4. // @description Reload pages every x minutes
  5. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  6. // @include *worldwidetorrents.eu*
  7. // @version 1
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. var numMinutes = 2; // number of minutes until reload
  12.  
  13. // --------- Do not edit below --------- //
  14.  
  15. $( document ).ready(function() {
  16.  
  17. $('.myLink7').after('<input type="button" id="rNum" class="running" title="Click to pause" style="position:relative;top:2px;">');
  18.  
  19. $('#rNum').click(function(){
  20. if($(this).attr("class") !== "paused"){
  21. $('#rNum').removeClass("running").addClass("paused");
  22. $('#rNum').attr('title','Click to resume');
  23. Clock.pause();
  24. }
  25. else{
  26. $('#rNum').removeClass("paused").addClass("running");
  27. $('#rNum').attr('title','Click to pause');
  28. Clock.resume();
  29. }
  30. });
  31. });
  32.  
  33.  
  34. var Clock = {
  35. totalSeconds: numMinutes*60,
  36. start: function () {
  37. var self = this;
  38. this.interval = setInterval(function () {
  39. self.totalSeconds -= 1;
  40. var min = Math.floor(self.totalSeconds / 60 % 60);
  41. if(min < 10){min = "0"+min;} // Leading zeros
  42. var sec = parseInt(self.totalSeconds % 60);
  43. if(sec < 10){sec = "0"+sec;} // Leading zeros
  44. document.getElementById('rNum').value = "Page Reload: "+min+":"+sec;
  45. if(self.totalSeconds <= 0){self.totalSeconds = numMinutes*60;location.reload(true);}
  46. }, 1000);
  47. },
  48. pause: function () {
  49. clearInterval(this.interval);
  50. delete this.interval;
  51. },
  52. resume: function () {
  53. if (!this.interval) this.start();
  54. }
  55. };
  56. Clock.start();