mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 09:07:54 +01:00
Prevent contentScripts.register
from throwing
Related issue: https://github.com/uBlockOrigin/uBlock-issues/issues/2915
This commit is contained in:
parent
bc632b5464
commit
b061db229e
1 changed files with 3 additions and 0 deletions
|
@ -78,6 +78,7 @@ const contentScriptRegisterer = new (class {
|
||||||
}
|
}
|
||||||
register(hostname, code) {
|
register(hostname, code) {
|
||||||
if ( browser.contentScripts === undefined ) { return false; }
|
if ( browser.contentScripts === undefined ) { return false; }
|
||||||
|
if ( hostname === '' ) { return false; }
|
||||||
const details = this.hostnameToDetails.get(hostname);
|
const details = this.hostnameToDetails.get(hostname);
|
||||||
if ( details !== undefined ) {
|
if ( details !== undefined ) {
|
||||||
if ( code === details.code ) {
|
if ( code === details.code ) {
|
||||||
|
@ -94,6 +95,8 @@ const contentScriptRegisterer = new (class {
|
||||||
runAt: 'document_start',
|
runAt: 'document_start',
|
||||||
}).then(handle => {
|
}).then(handle => {
|
||||||
this.hostnameToDetails.set(hostname, { handle, code });
|
this.hostnameToDetails.set(hostname, { handle, code });
|
||||||
|
}).catch(( ) => {
|
||||||
|
this.hostnameToDetails.delete(hostname);
|
||||||
});
|
});
|
||||||
this.hostnameToDetails.set(hostname, { handle: promise, code });
|
this.hostnameToDetails.set(hostname, { handle: promise, code });
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue