rAthus icon

[UserScript] Annoying Random Page Reload

rAthus | PRO | 05/18/18 10:27:24 AM UTC | 0 ⭐ | 780 👁️ | Never ⏰ | []
JavaScript |

860 B

|

None

|

0 👍

/

0 👎

// ==UserScript==
// @name         Annoying Random Page Reload
// @namespace    Topkek
// @version      0.1
// @description  Randomly reloads page between set minumim and maximum delays
// @author       rAthus
// @match        *://*/*
// @grant        none
// ==/UserScript==
(function() {
    'use strict';
    var min_minutes = 3; // minimum delay before realoading the page
    var max_minutes = 6; // maximum delay before realoading the page
    if (window.self===window.top)
    {
        var t = Math.round(min_minutes*60+Math.random()*(max_minutes-min_minutes)*60)*1000;
        var m = Math.floor(t/60000);
        var s = ('0'+(t-m*60000)/1000).slice(-2);
        var d = new Date((+ new Date())+t);
        console.log('Topkek in '+m+'m'+s+'s (at '+d.getHours()+'h'+('0'+d.getMinutes()).slice(-2)+'m'+('0'+d.getSeconds()).slice(-2)+'s)');
        setTimeout(function(){location.reload();},t);
    }
})();

Comments