25
25
26
26
// Load all: executed once.
27
27
28
-
µBlock.restart = (function() {
29
-
30
-
/******************************************************************************/
28
+
{
29
+
// >>>>> start of local scope
31
30
32
31
const µb = µBlock;
33
32
34
33
/******************************************************************************/
35
34
36
35
vAPI.app.onShutdown = function() {
36
+
const µb = µBlock;
37
37
µb.staticFilteringReverseLookup.shutdown();
38
38
µb.assets.updateStop();
39
39
µb.staticNetFilteringEngine.reset();
@@ -52,7 +52,7 @@ vAPI.app.onShutdown = function() {
52
52
// - Initialize internal state with maybe already existing tabs.
53
53
// - Schedule next update operation.
54
54
55
-
var onAllReady = function() {
55
+
const onAllReady = function() {
56
56
µb.webRequest.start();
57
57
58
58
// Ensure that the resources allocated for decompression purpose (likely
@@ -86,6 +86,18 @@ var onAllReady = function() {
86
86
µb.contextMenu.update(null);
87
87
µb.firstInstall = false;
88
88
89
+
// https://github.com/uBlockOrigin/uBlock-issues/issues/717
90
+
// Prevent the extensions from being restarted mid-session.
91
+
browser.runtime.onUpdateAvailable.addListener(details => {
92
+
const toInt = vAPI.app.intFromVersion;
93
+
if (
94
+
µBlock.hiddenSettings.extensionUpdateForceReload === true ||
95
+
toInt(details.version) <= toInt(vAPI.app.version)
96
+
) {
97
+
vAPI.app.restart();
98
+
}
99
+
});
100
+
89
101
log.info(`All ready ${Date.now()-vAPI.T0} ms after launch`);
90
102
};
91
103
@@ -96,8 +108,8 @@ var onAllReady = function() {
96
108
// in already opened web pages, to remove whatever nuisance could make it to
97
109
// the web pages before uBlock was ready.
98
110
99
-
let initializeTabs = function() {
100
-
let handleScriptResponse = function(tabId, results) {
111
+
const initializeTabs = function() {
112
+
const handleScriptResponse = function(tabId, results) {
101
113
if (
102
114
Array.isArray(results) === false ||
103
115
results.length === 0 ||
@@ -106,10 +118,10 @@ let initializeTabs = function() {
106
118
return;
107
119
}
108
120
// Inject dclarative content scripts programmatically.
109
-
let manifest = chrome.runtime.getManifest();
121
+
const manifest = chrome.runtime.getManifest();
110
122
if ( manifest instanceof Object === false ) { return; }
111
-
for ( let contentScript of manifest.content_scripts ) {
112
-
for ( let file of contentScript.js ) {
123
+
for ( const contentScript of manifest.content_scripts ) {
124
+
for ( const file of contentScript.js ) {
113
125
vAPI.tabs.injectScript(tabId, {
114
126
file: file,
115
127
allFrames: contentScript.all_frames,
@@ -118,8 +130,8 @@ let initializeTabs = function() {
118
130
}
119
131
}
120
132
};
121
-
let bindToTabs = function(tabs) {
122
-
for ( let tab of tabs ) {
133
+
const bindToTabs = function(tabs) {
134
+
for ( const tab of tabs ) {
123
135
µb.tabContextManager.commit(tab.id, tab.url);
124
136
µb.bindTabToPageStats(tab.id);
125
137
// https://github.com/chrisaljoudi/uBlock/issues/129
@@ -241,7 +253,7 @@ const onUserSettingsReady = function(fetched) {
241
253
// Housekeeping, as per system setting changes
242
254
243
255
const onSystemSettingsReady = function(fetched) {
244
-
var mustSaveSystemSettings = false;
256
+
let mustSaveSystemSettings = false;
245
257
if ( fetched.compiledMagic !== µb.systemSettings.compiledMagic ) {
246
258
µb.assets.remove(/^compiled\//);
247
259
mustSaveSystemSettings = true;
@@ -367,17 +379,10 @@ const onAdminSettingsRestored = function() {
367
379
368
380
/******************************************************************************/
369
381
370
-
return function() {
371
-
// https://github.com/gorhill/uBlock/issues/531
372
-
µb.restoreAdminSettings().then(( ) => {
373
-
onAdminSettingsRestored();
374
-
});
375
-
};
376
-
377
-
/******************************************************************************/
378
-
379
-
})();
380
-
381
-
/******************************************************************************/
382
+
// https://github.com/gorhill/uBlock/issues/531
383
+
µb.restoreAdminSettings().then(( ) => {
384
+
onAdminSettingsRestored();
385
+
});
382
386
383
-
µBlock.restart();
387
+
// <<<<< end of local scope
388
+
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4