mirror of https://github.com/gorhill/uBlock.git
Do not rely on `vAPI` presence in logger broadcast code
Related feedback: https://github.com/uBlockOrigin/uBlock-issues/discussions/3096#discussioncomment-8339494
This commit is contained in:
parent
605c830312
commit
b0122bb9fc
|
@ -175,9 +175,7 @@ const onScriptletMessageInjector = (( ) => {
|
|||
const parts = [
|
||||
'(',
|
||||
function(name) {
|
||||
if ( typeof vAPI !== 'object' ) { return; }
|
||||
if ( vAPI === null ) { return; }
|
||||
if ( vAPI.bcSecret ) { return; }
|
||||
if ( self.uBO_bcSecret ) { return; }
|
||||
const bcSecret = new self.BroadcastChannel(name);
|
||||
bcSecret.onmessage = ev => {
|
||||
const msg = ev.data;
|
||||
|
@ -189,14 +187,12 @@ const onScriptletMessageInjector = (( ) => {
|
|||
case 'object':
|
||||
if ( self.vAPI && self.vAPI.messaging ) {
|
||||
self.vAPI.messaging.send('contentscript', msg);
|
||||
} else {
|
||||
bcSecret.onmessage = null;
|
||||
}
|
||||
break;
|
||||
}
|
||||
};
|
||||
bcSecret.postMessage('iamready!');
|
||||
vAPI.bcSecret = bcSecret;
|
||||
self.uBO_bcSecret = bcSecret;
|
||||
}.toString(),
|
||||
')(',
|
||||
'bcSecret-slot',
|
||||
|
|
|
@ -24,9 +24,8 @@
|
|||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
if ( typeof vAPI !== 'object' || vAPI === null ) { return; }
|
||||
if ( vAPI.bcSecret instanceof self.BroadcastChannel === false ) { return; }
|
||||
vAPI.bcSecret.postMessage('setScriptletLogLevelToOne');
|
||||
if ( self.uBO_bcSecret instanceof self.BroadcastChannel === false ) { return; }
|
||||
self.uBO_bcSecret.postMessage('setScriptletLogLevelToOne');
|
||||
})();
|
||||
|
||||
|
||||
|
|
|
@ -24,9 +24,8 @@
|
|||
/******************************************************************************/
|
||||
|
||||
(( ) => {
|
||||
if ( typeof vAPI !== 'object' || vAPI === null ) { return; }
|
||||
if ( vAPI.bcSecret instanceof self.BroadcastChannel === false ) { return; }
|
||||
vAPI.bcSecret.postMessage('setScriptletLogLevelToTwo');
|
||||
if ( self.uBO_bcSecret instanceof self.BroadcastChannel === false ) { return; }
|
||||
self.uBO_bcSecret.postMessage('setScriptletLogLevelToTwo');
|
||||
})();
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue