Advertisement
rAthus

[UserScript] Annoying Random Page Reload

May 18th, 2018
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Annoying Random Page Reload
  3. // @namespace    Topkek
  4. // @version      0.1
  5. // @description  Randomly reloads page between set minumim and maximum delays
  6. // @author       rAthus
  7. // @match        *://*/*
  8. // @grant        none
  9. // ==/UserScript==
  10. (function() {
  11.     'use strict';
  12.     var min_minutes = 3; // minimum delay before realoading the page
  13.     var max_minutes = 6; // maximum delay before realoading the page
  14.     if (window.self===window.top)
  15.     {
  16.         var t = Math.round(min_minutes*60+Math.random()*(max_minutes-min_minutes)*60)*1000;
  17.         var m = Math.floor(t/60000);
  18.         var s = ('0'+(t-m*60000)/1000).slice(-2);
  19.         var d = new Date((+ new Date())+t);
  20.         console.log('Topkek in '+m+'m'+s+'s (at '+d.getHours()+'h'+('0'+d.getMinutes()).slice(-2)+'m'+('0'+d.getSeconds()).slice(-2)+'s)');
  21.         setTimeout(function(){location.reload();},t);
  22.     }
  23. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement