-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathinject_block.js
42 lines (38 loc) · 1.31 KB
/
inject_block.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
42
var PAUSE_TIME = 30000; // in milliseconds
var checkToPauseButton = document.getElementById("NMD_pause");
const getPauseStatus = localStorage.getItem('pausingNMD');
// TODO: Improve Pause functionality
if(checkToPauseButton!=undefined){
checkToPauseButton.addEventListener("click",()=>{
if(getPauseStatus!=undefined){
if(getPauseStatus==="yes"){
setTimeout(
()=>{
chrome.storage.local.set({ toggle_value: "on" });
chrome.runtime.sendMessage({ NMD_status: "on" });
}, PAUSE_TIME);
localStorage.removeItem("pausingNMD");
window.history.go(0);
console.log(history.length);
}else{
localStorage.setItem("pausingNMD","yes");
chrome.storage.local.set({ toggle_value: "off" });
chrome.runtime.sendMessage({ NMD_status: "off" });
}
}else{
localStorage.setItem("pausingNMD","yes");
chrome.storage.local.set({ toggle_value: "off" });
chrome.runtime.sendMessage({ NMD_status: "off" });
setTimeout(
()=>{
chrome.storage.local.set({ toggle_value: "on" });
chrome.runtime.sendMessage({ NMD_status: "on" });
}, PAUSE_TIME);
localStorage.removeItem("pausingNMD");
window.history.go(-1);
}
});
}
else{
console.log("Undef");
}