1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 12:50:36 +01:00

Update improvements

For #522
This commit is contained in:
kkapsner 2021-01-26 13:47:11 +01:00
parent e48710eee9
commit 8e5986817e
5 changed files with 39 additions and 1 deletions

View File

@ -185,6 +185,15 @@
"description": ""
},
"disruptSessionOnUpdate_title": {
"message": "Disrupt session on update",
"description": ""
},
"disruptSessionOnUpdate_description": {
"message": "If set to true the extension will update as soon as the update is available. This might break some tabs that are currently open.",
"description": ""
},
"hideSetting": {
"message": "Click here to hide this setting.",
"description": ""

View File

@ -199,5 +199,26 @@
});
});
}
if (browser.runtime.onUpdateAvailable){
browser.runtime.onUpdateAvailable.addListener(async function(details){
logging.message("Update available", details);
if (settings.disruptSessionOnUpdate){
await Promise.all((await browser.tabs.query({})).map(async function(tab){
try{
await browser.tabs.sendMessage(tab.id, {
"canvasBlocker-unload": true
});
}
catch(error){
logging.verbose("error while unloading", tab, ":", error);
}
}));
window.setTimeout(function(){
logging.verbose("Reload extension after one second");
browser.runtime.reload();
}, 1000);
}
});
}
logging.message("end");
}());

View File

@ -408,6 +408,10 @@
name: "dontShowOptionsOnUpdate",
defaultValue: false
},
{
name: "disruptSessionOnUpdate",
defaultValue: false
},
{
name: "isStillDefault",
defaultValue: true

View File

@ -16,6 +16,9 @@
{
"name": "blockMode"
},
{
"name": "disruptSessionOnUpdate"
},
]
},
{

View File

@ -3,7 +3,8 @@ Version 1.6:
-
new features:
-
- try to not break tabs when updating
- setting to postpone updates until browser restart
fixes:
- fix message canvasBlocker-unload