mirror of https://github.com/gorhill/uBlock.git
Unregister all scriptlets when disabling uBO on a specific site
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/3083 This will not completely eliminate the issue but it should lower the likelihood it will occur -- so at least uBO can still benefit from reliable scriptlet execution in Firefox.
This commit is contained in:
parent
5e9a7c60db
commit
13dcd844a7
|
@ -45,10 +45,13 @@ const contentScriptRegisterer = new (class {
|
|||
constructor() {
|
||||
this.hostnameToDetails = new Map();
|
||||
if ( browser.contentScripts === undefined ) { return; }
|
||||
onBroadcast(msg => {
|
||||
this.bc = onBroadcast(msg => {
|
||||
if ( msg.what !== 'filteringBehaviorChanged' ) { return; }
|
||||
if ( msg.direction > 0 ) { return; }
|
||||
if ( msg.hostname ) { return this.flush(msg.hostname); }
|
||||
const direction = msg.direction || 0;
|
||||
if ( direction > 0 ) { return; }
|
||||
if ( direction >= 0 && msg.hostname ) {
|
||||
return this.flush(msg.hostname);
|
||||
}
|
||||
this.reset();
|
||||
});
|
||||
}
|
||||
|
@ -78,6 +81,7 @@ const contentScriptRegisterer = new (class {
|
|||
return false;
|
||||
}
|
||||
unregister(hostname) {
|
||||
if ( hostname === '' ) { return; }
|
||||
if ( this.hostnameToDetails.size === 0 ) { return; }
|
||||
const details = this.hostnameToDetails.get(hostname);
|
||||
if ( details === undefined ) { return; }
|
||||
|
@ -85,6 +89,7 @@ const contentScriptRegisterer = new (class {
|
|||
this.unregisterHandle(details.handle);
|
||||
}
|
||||
flush(hostname) {
|
||||
if ( hostname === '' ) { return; }
|
||||
if ( hostname === '*' ) { return this.reset(); }
|
||||
for ( const hn of this.hostnameToDetails.keys() ) {
|
||||
if ( hn.endsWith(hostname) === false ) { continue; }
|
||||
|
|
|
@ -148,7 +148,7 @@ const matchBucket = function(url, hostname, bucket, start) {
|
|||
}
|
||||
bucket.push(directive);
|
||||
this.saveWhitelist();
|
||||
filteringBehaviorChanged({ hostname: targetHostname });
|
||||
filteringBehaviorChanged({ hostname: targetHostname, direction: -1 });
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue