mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
Prevent uBO from being reloaded mid-session
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/717 Just registering a onUpdateAvailable() listener prevents the browser from reloading the extension mid-session. Ref: - https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onUpdateAvailable
This commit is contained in:
parent
b5e34f12fc
commit
59bdf2b4cc
@ -26,7 +26,8 @@
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
(( ) => {
|
{
|
||||||
|
// >>>>> start of local scope
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -65,32 +66,35 @@ const noopFunc = function(){};
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
vAPI.app = (function() {
|
vAPI.app = {
|
||||||
let version = manifest.version;
|
name: manifest.name.replace(/ dev\w+ build/, ''),
|
||||||
let match = /(\d+\.\d+\.\d+)(?:\.(\d+))?/.exec(version);
|
version: (( ) => {
|
||||||
if ( match && match[2] ) {
|
let version = manifest.version;
|
||||||
let v = parseInt(match[2], 10);
|
const match = /(\d+\.\d+\.\d+)(?:\.(\d+))?/.exec(version);
|
||||||
version = match[1] + (v < 100 ? 'b' + v : 'rc' + (v - 100));
|
if ( match && match[2] ) {
|
||||||
}
|
const v = parseInt(match[2], 10);
|
||||||
|
version = match[1] + (v < 100 ? 'b' + v : 'rc' + (v - 100));
|
||||||
|
}
|
||||||
|
return version;
|
||||||
|
})(),
|
||||||
|
|
||||||
return {
|
restart: function() {
|
||||||
name: manifest.name.replace(/ dev\w+ build/, ''),
|
browser.runtime.reload();
|
||||||
version: version
|
},
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
vAPI.app.restart = function() {
|
|
||||||
chrome.runtime.reload();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/717
|
||||||
|
// Prevent the extensions from being restarted mid-session.
|
||||||
|
browser.runtime.onUpdateAvailable.addListener(( ) => {
|
||||||
|
void 0;
|
||||||
|
});
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// chrome.storage.local.get(null, function(bin){ console.debug('%o', bin); });
|
// chrome.storage.local.get(null, function(bin){ console.debug('%o', bin); });
|
||||||
|
|
||||||
vAPI.storage = chrome.storage.local;
|
vAPI.storage = browser.storage.local;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
@ -217,7 +221,7 @@ vAPI.browserSettings = (function() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
set: function(details) {
|
set: function(details) {
|
||||||
for ( var setting in details ) {
|
for ( const setting in details ) {
|
||||||
if ( details.hasOwnProperty(setting) === false ) {
|
if ( details.hasOwnProperty(setting) === false ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1222,11 +1226,10 @@ vAPI.contextMenu = chrome.contextMenus && {
|
|||||||
onMustUpdate: function() {},
|
onMustUpdate: function() {},
|
||||||
setEntries: function(entries, callback) {
|
setEntries: function(entries, callback) {
|
||||||
entries = entries || [];
|
entries = entries || [];
|
||||||
var n = Math.max(this._entries.length, entries.length),
|
let n = Math.max(this._entries.length, entries.length);
|
||||||
oldEntryId, newEntry;
|
for ( let i = 0; i < n; i++ ) {
|
||||||
for ( var i = 0; i < n; i++ ) {
|
const oldEntryId = this._entries[i];
|
||||||
oldEntryId = this._entries[i];
|
const newEntry = entries[i];
|
||||||
newEntry = entries[i];
|
|
||||||
if ( oldEntryId && newEntry ) {
|
if ( oldEntryId && newEntry ) {
|
||||||
if ( newEntry.id !== oldEntryId ) {
|
if ( newEntry.id !== oldEntryId ) {
|
||||||
chrome.contextMenus.remove(oldEntryId);
|
chrome.contextMenus.remove(oldEntryId);
|
||||||
@ -1277,8 +1280,8 @@ vAPI.commands = chrome.commands;
|
|||||||
|
|
||||||
vAPI.adminStorage = chrome.storage.managed && {
|
vAPI.adminStorage = chrome.storage.managed && {
|
||||||
getItem: function(key, callback) {
|
getItem: function(key, callback) {
|
||||||
var onRead = function(store) {
|
const onRead = function(store) {
|
||||||
var data;
|
let data;
|
||||||
if (
|
if (
|
||||||
!chrome.runtime.lastError &&
|
!chrome.runtime.lastError &&
|
||||||
typeof store === 'object' &&
|
typeof store === 'object' &&
|
||||||
@ -1513,6 +1516,7 @@ vAPI.cloud = (function() {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
})();
|
// <<<<< end of local scope
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user