forked from WitchTP/Tagpro-Userscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefresher.js
34 lines (28 loc) · 1.01 KB
/
refresher.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// ==UserScript==
// @name Mod Tools Refresher
// @updateURL https://raw.githubusercontent.com/WitchTP/Tagpro-Userscripts/master/refresher.js
// @include http://tagpro-*.koalabeast.com/moderate/*
// @include http://tangent.jukejuice.com/moderate/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js
// @version 1.0
// @description Refreshes mod tools every 10 seconds (can be configured in the script)
// @author Contessa
// ==/UserScript==
var interval = 10000; // given in terms of milliseconds (1000 is 1 second)
function getCurrentTime() {
return new Date().getTime();
};
var time = getCurrentTime();
$(document.body).bind('mousemove mousedown mouseup keypress', function(e) {
time = getCurrentTime(); // reset time on user activity
});
function refresh() {
if (getCurrentTime() - time >= interval) {
window.location.reload(true);
} else {
setTimeout(refresh, interval);
}
};
$(function() {
setTimeout(refresh, interval);
});