mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-03-13 11:44:12 +01:00
Cleanup CanvasBlocker
once Firefox supports browser.runtime.onSuspend
This commit is contained in:
parent
9353f71455
commit
6c22788096
15
lib/frame.js
15
lib/frame.js
@ -45,13 +45,13 @@
|
|||||||
|
|
||||||
let extensionSecret;
|
let extensionSecret;
|
||||||
function computeExtensionSecret(){
|
function computeExtensionSecret(){
|
||||||
function hashString(string){
|
function hashString(string){
|
||||||
return hashing(new Uint16Array(
|
return hashing(new Uint16Array(
|
||||||
string.split("").map(function(c){
|
string.split("").map(function(c){
|
||||||
return c.charCodeAt(0);
|
return c.charCodeAt(0);
|
||||||
})
|
})
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const lastTenMinutes = Math.floor(now.getMinutes() / 10) * 10;
|
const lastTenMinutes = Math.floor(now.getMinutes() / 10) * 10;
|
||||||
const nextRun = new Date(
|
const nextRun = new Date(
|
||||||
@ -203,6 +203,7 @@
|
|||||||
logging.message("register listener for messages from background script");
|
logging.message("register listener for messages from background script");
|
||||||
extension.message.on(function(data){
|
extension.message.on(function(data){
|
||||||
if (data["canvasBlocker-unload"]){
|
if (data["canvasBlocker-unload"]){
|
||||||
|
extension.revertProperties();
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
|
12
lib/main.js
12
lib/main.js
@ -188,6 +188,16 @@
|
|||||||
mobile.applyMobileDefaults(settings);
|
mobile.applyMobileDefaults(settings);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (browser.runtime.onSuspend){
|
||||||
|
browser.runtime.onSuspend.addListener(async function(){
|
||||||
|
logging.message("Suspending CanvasBlocker");
|
||||||
|
(await browser.tabs.query({})).forEach(function(tab){
|
||||||
|
browser.tabs.sendMessage(tab.id, {
|
||||||
|
"canvasBlocker-unload": true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
logging.message("end");
|
logging.message("end");
|
||||||
}());
|
}());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user