mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-02 17:19:38 +02:00
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() {
|
constructor() {
|
||||||
this.hostnameToDetails = new Map();
|
this.hostnameToDetails = new Map();
|
||||||
if ( browser.contentScripts === undefined ) { return; }
|
if ( browser.contentScripts === undefined ) { return; }
|
||||||
onBroadcast(msg => {
|
this.bc = onBroadcast(msg => {
|
||||||
if ( msg.what !== 'filteringBehaviorChanged' ) { return; }
|
if ( msg.what !== 'filteringBehaviorChanged' ) { return; }
|
||||||
if ( msg.direction > 0 ) { return; }
|
const direction = msg.direction || 0;
|
||||||
if ( msg.hostname ) { return this.flush(msg.hostname); }
|
if ( direction > 0 ) { return; }
|
||||||
|
if ( direction >= 0 && msg.hostname ) {
|
||||||
|
return this.flush(msg.hostname);
|
||||||
|
}
|
||||||
this.reset();
|
this.reset();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -78,6 +81,7 @@ const contentScriptRegisterer = new (class {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
unregister(hostname) {
|
unregister(hostname) {
|
||||||
|
if ( hostname === '' ) { return; }
|
||||||
if ( this.hostnameToDetails.size === 0 ) { return; }
|
if ( this.hostnameToDetails.size === 0 ) { return; }
|
||||||
const details = this.hostnameToDetails.get(hostname);
|
const details = this.hostnameToDetails.get(hostname);
|
||||||
if ( details === undefined ) { return; }
|
if ( details === undefined ) { return; }
|
||||||
@ -85,6 +89,7 @@ const contentScriptRegisterer = new (class {
|
|||||||
this.unregisterHandle(details.handle);
|
this.unregisterHandle(details.handle);
|
||||||
}
|
}
|
||||||
flush(hostname) {
|
flush(hostname) {
|
||||||
|
if ( hostname === '' ) { return; }
|
||||||
if ( hostname === '*' ) { return this.reset(); }
|
if ( hostname === '*' ) { return this.reset(); }
|
||||||
for ( const hn of this.hostnameToDetails.keys() ) {
|
for ( const hn of this.hostnameToDetails.keys() ) {
|
||||||
if ( hn.endsWith(hostname) === false ) { continue; }
|
if ( hn.endsWith(hostname) === false ) { continue; }
|
||||||
|
@ -148,7 +148,7 @@ const matchBucket = function(url, hostname, bucket, start) {
|
|||||||
}
|
}
|
||||||
bucket.push(directive);
|
bucket.push(directive);
|
||||||
this.saveWhitelist();
|
this.saveWhitelist();
|
||||||
filteringBehaviorChanged({ hostname: targetHostname });
|
filteringBehaviorChanged({ hostname: targetHostname, direction: -1 });
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user