mirror of https://github.com/gorhill/uBlock.git
Flush memory cache at key filtering profile changes
To reduce the need for hard reload after changes in filters, rules.
This commit is contained in:
parent
daee72b982
commit
6e8aeae283
|
@ -1298,6 +1298,9 @@ vAPI.Net = class {
|
||||||
this.listenerMap.set(clientListener, actualListener);
|
this.listenerMap.set(clientListener, actualListener);
|
||||||
return actualListener;
|
return actualListener;
|
||||||
}
|
}
|
||||||
|
handlerBehaviorChanged() {
|
||||||
|
browser.webRequest.handlerBehaviorChanged();
|
||||||
|
}
|
||||||
onUnprocessedRequest(details) {
|
onUnprocessedRequest(details) {
|
||||||
const { tabId } = details;
|
const { tabId } = details;
|
||||||
if ( tabId === -1 ) { return; }
|
if ( tabId === -1 ) { return; }
|
||||||
|
|
|
@ -459,6 +459,10 @@ if ( selfieIsValid !== true ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Flush memory cache -- unsure whether the browser does this internally
|
||||||
|
// when loading a new extension.
|
||||||
|
vAPI.net.handlerBehaviorChanged();
|
||||||
|
|
||||||
// Final initialization steps after all needed assets are in memory.
|
// Final initialization steps after all needed assets are in memory.
|
||||||
|
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/974
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/974
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
Home: https://github.com/gorhill/uBlock
|
Home: https://github.com/gorhill/uBlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* globals browser, WebAssembly */
|
/* globals WebAssembly */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -581,9 +581,7 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
|
||||||
|
|
||||||
// https://www.reddit.com/r/uBlockOrigin/comments/cj7g7m/
|
// https://www.reddit.com/r/uBlockOrigin/comments/cj7g7m/
|
||||||
// https://www.reddit.com/r/uBlockOrigin/comments/cnq0bi/
|
// https://www.reddit.com/r/uBlockOrigin/comments/cnq0bi/
|
||||||
if ( options.killCache ) {
|
vAPI.net.handlerBehaviorChanged();
|
||||||
browser.webRequest.handlerBehaviorChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
vAPI.messaging.broadcast({ what: 'userFiltersUpdated' });
|
vAPI.messaging.broadcast({ what: 'userFiltersUpdated' });
|
||||||
};
|
};
|
||||||
|
@ -818,6 +816,7 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
|
||||||
staticExtFilteringEngine.freeze();
|
staticExtFilteringEngine.freeze();
|
||||||
redirectEngine.freeze();
|
redirectEngine.freeze();
|
||||||
vAPI.net.unsuspend();
|
vAPI.net.unsuspend();
|
||||||
|
vAPI.net.handlerBehaviorChanged();
|
||||||
|
|
||||||
vAPI.storage.set({ 'availableFilterLists': µb.availableFilterLists });
|
vAPI.storage.set({ 'availableFilterLists': µb.availableFilterLists });
|
||||||
|
|
||||||
|
|
|
@ -187,6 +187,10 @@ const matchBucket = function(url, hostname, bucket, start) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.saveWhitelist();
|
this.saveWhitelist();
|
||||||
|
|
||||||
|
// Flush memory cache
|
||||||
|
vAPI.net.handlerBehaviorChanged();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -521,6 +525,11 @@ const matchBucket = function(url, hostname, bucket, start) {
|
||||||
// https://github.com/chrisaljoudi/uBlock/issues/420
|
// https://github.com/chrisaljoudi/uBlock/issues/420
|
||||||
cosmeticFilteringEngine.removeFromSelectorCache(srcHostname, 'net');
|
cosmeticFilteringEngine.removeFromSelectorCache(srcHostname, 'net');
|
||||||
|
|
||||||
|
// Flush memory cache
|
||||||
|
if ( action === 1 ) {
|
||||||
|
vAPI.net.handlerBehaviorChanged();
|
||||||
|
}
|
||||||
|
|
||||||
if ( details.tabId === undefined ) { return; }
|
if ( details.tabId === undefined ) { return; }
|
||||||
|
|
||||||
if ( requestType.startsWith('3p') ) {
|
if ( requestType.startsWith('3p') ) {
|
||||||
|
@ -577,25 +586,39 @@ const matchBucket = function(url, hostname, bucket, start) {
|
||||||
);
|
);
|
||||||
if ( changed === false ) { return; }
|
if ( changed === false ) { return; }
|
||||||
|
|
||||||
// Take action if needed
|
// Take per-switch action if needed
|
||||||
switch ( details.name ) {
|
switch ( details.name ) {
|
||||||
case 'no-scripting':
|
case 'no-scripting':
|
||||||
this.updateToolbarIcon(details.tabId, 0b100);
|
this.updateToolbarIcon(details.tabId, 0b100);
|
||||||
break;
|
break;
|
||||||
case 'no-cosmetic-filtering': {
|
case 'no-cosmetic-filtering': {
|
||||||
const scriptlet = newState ? 'cosmetic-off' : 'cosmetic-on';
|
const scriptlet = newState ? 'cosmetic-off' : 'cosmetic-on';
|
||||||
vAPI.tabs.executeScript(details.tabId, {
|
vAPI.tabs.executeScript(details.tabId, {
|
||||||
file: `/js/scriptlets/${scriptlet}.js`,
|
file: `/js/scriptlets/${scriptlet}.js`,
|
||||||
allFrames: true,
|
allFrames: true,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'no-large-media':
|
case 'no-large-media':
|
||||||
const pageStore = this.pageStoreFromTabId(details.tabId);
|
const pageStore = this.pageStoreFromTabId(details.tabId);
|
||||||
if ( pageStore !== null ) {
|
if ( pageStore !== null ) {
|
||||||
pageStore.temporarilyAllowLargeMediaElements(!newState);
|
pageStore.temporarilyAllowLargeMediaElements(!newState);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flush memory cache if needed
|
||||||
|
if ( newState ) {
|
||||||
|
switch ( details.name ) {
|
||||||
|
case 'no-scripting':
|
||||||
|
case 'no-remote-fonts':
|
||||||
|
vAPI.net.handlerBehaviorChanged();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( details.persist !== true ) { return; }
|
if ( details.persist !== true ) { return; }
|
||||||
|
|
Loading…
Reference in New Issue