-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
41 lines (29 loc) · 1.12 KB
/
background.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
35
36
37
38
39
40
41
var x = setInterval(function () {
if (localStorage.getItem("data_string") === null) {} else {
var json = JSON.parse(localStorage.data_string);
for (var index = 0; index < json.length; ++index) {
var data = json[index];
change(data);
}
localStorage.data_string = JSON.stringify(json)
}
}, 1000);
function change(data) {
data.value = data.value - 1;
//document.getElementById("output").innerHTML = value;
if (data.value < 0) {
// clearInterval(x);
//document.getElementById("output").innerHTML = "EXPIRED";
var min = localStorage.min;
data.value = parseInt(Math.floor(Math.random() * data.diff)) + parseInt(data.min);
//document.getElementById("output").innerHTML = value;
chrome.tabs.query({
url: data.url
}, function (tabs) {
tabs.forEach((tab) => {
chrome.tabs.reload(tab.id)
})
// reload tab with one of the methods from linked answer
})
}
}