diff --git a/src/js/scriptlet-filtering.js b/src/js/scriptlet-filtering.js index 98f2a64a3..e221a4197 100644 --- a/src/js/scriptlet-filtering.js +++ b/src/js/scriptlet-filtering.js @@ -61,6 +61,7 @@ const contentScriptRegisterer = new (class { runAt: 'document_start', }).then(handle => { this.hostnameToDetails.set(hostname, { handle, code }); + return handle; }).catch(( ) => { this.hostnameToDetails.delete(hostname); }); @@ -94,7 +95,9 @@ const contentScriptRegisterer = new (class { } unregisterHandle(handle) { if ( handle instanceof Promise ) { - handle.then(handle => { handle.unregister(); }); + handle.then(handle => { + if ( handle ) { handle.unregister(); } + }); } else { handle.unregister(); }