mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-23 02:42:41 +01:00
Fix verbose mode not applying to newly injected scriptlets
Related commit:
869a653fdf
This commit is contained in:
parent
aa56fe1224
commit
49a6dc868f
@ -158,7 +158,7 @@ function safeSelf() {
|
||||
};
|
||||
if ( scriptletGlobals.bcSecret !== undefined ) {
|
||||
const bc = new self.BroadcastChannel(scriptletGlobals.bcSecret);
|
||||
safe.logLevel = 1;
|
||||
safe.logLevel = scriptletGlobals.logLevel || 1;
|
||||
safe.sendToLogger = (type, ...args) => {
|
||||
if ( args.length === 0 ) { return; }
|
||||
const text = `[${document.location.hostname || document.location.href}]${args.join(' ')}`;
|
||||
@ -692,7 +692,10 @@ function replaceNodeTextFn(
|
||||
? before.replace(rePattern, replacement)
|
||||
: replacement;
|
||||
node.textContent = after;
|
||||
safe.uboLog(logPrefix, `Replace result:\n${after.trim()}`);
|
||||
if ( safe.logLevel > 1 ) {
|
||||
safe.uboLog(logPrefix, `Text before:\n${before.trim()}`);
|
||||
}
|
||||
safe.uboLog(logPrefix, `Text after:\n${after.trim()}`);
|
||||
return sedCount === 0 || (sedCount -= 1) !== 0;
|
||||
};
|
||||
const handleMutations = mutations => {
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
import webext from './webext.js';
|
||||
import { broadcast } from './broadcast.js';
|
||||
import { hostnameFromURI } from './uri-utils.js';
|
||||
import { i18n, i18n$ } from './i18n.js';
|
||||
import { dom, qs$, qsa$ } from './dom.js';
|
||||
@ -3043,20 +3043,7 @@ dom.on('#pause', 'click', pauseNetInspector);
|
||||
|
||||
dom.on('#logLevel', 'click', ev => {
|
||||
const level = dom.cl.toggle(ev.currentTarget, 'active') ? 2 : 1;
|
||||
webext.tabs.query({
|
||||
discarded: false,
|
||||
url: [ 'http://*/*', 'https://*/*' ],
|
||||
}).then(tabs => {
|
||||
for ( const tab of tabs ) {
|
||||
const { status } = tab;
|
||||
if ( status !== 'loading' && status !== 'complete' ) { continue; }
|
||||
webext.tabs.executeScript(tab.id, {
|
||||
allFrames: true,
|
||||
file: `/js/scriptlets/scriptlet-loglevel-${level}.js`,
|
||||
matchAboutBlank: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
broadcast({ what: 'loggerLevelChanged', level });
|
||||
});
|
||||
|
||||
dom.on('#netInspector', 'copy', ev => {
|
||||
|
@ -210,6 +210,7 @@ export class ScriptletFilteringEngineEx extends ScriptletFilteringEngine {
|
||||
this.warSecret = undefined;
|
||||
this.scriptletCache = new MRUCache(32);
|
||||
this.isDevBuild = undefined;
|
||||
this.logLevel = 1;
|
||||
this.bc = onBroadcast(msg => {
|
||||
switch ( msg.what ) {
|
||||
case 'filteringBehaviorChanged': {
|
||||
@ -226,8 +227,25 @@ export class ScriptletFilteringEngineEx extends ScriptletFilteringEngine {
|
||||
/* fall through */
|
||||
case 'loggerEnabled':
|
||||
case 'loggerDisabled':
|
||||
this.scriptletCache.reset();
|
||||
contentScriptRegisterer.reset();
|
||||
this.clearCache();
|
||||
break;
|
||||
case 'loggerLevelChanged':
|
||||
this.logLevel = msg.level;
|
||||
vAPI.tabs.query({
|
||||
discarded: false,
|
||||
url: [ 'http://*/*', 'https://*/*' ],
|
||||
}).then(tabs => {
|
||||
for ( const tab of tabs ) {
|
||||
const { status } = tab;
|
||||
if ( status !== 'loading' && status !== 'complete' ) { continue; }
|
||||
vAPI.tabs.executeScript(tab.id, {
|
||||
allFrames: true,
|
||||
file: `/js/scriptlets/scriptlet-loglevel-${this.logLevel}.js`,
|
||||
matchAboutBlank: true,
|
||||
});
|
||||
}
|
||||
});
|
||||
this.clearCache();
|
||||
break;
|
||||
}
|
||||
});
|
||||
@ -247,6 +265,11 @@ export class ScriptletFilteringEngineEx extends ScriptletFilteringEngine {
|
||||
contentScriptRegisterer.reset();
|
||||
}
|
||||
|
||||
clearCache() {
|
||||
this.scriptletCache.reset();
|
||||
contentScriptRegisterer.reset();
|
||||
}
|
||||
|
||||
retrieve(request) {
|
||||
const { hostname } = request;
|
||||
|
||||
@ -289,6 +312,7 @@ export class ScriptletFilteringEngineEx extends ScriptletFilteringEngine {
|
||||
};
|
||||
if ( logger.enabled ) {
|
||||
options.scriptletGlobals.bcSecret = bcSecret;
|
||||
options.scriptletGlobals.logLevel = this.logLevel;
|
||||
}
|
||||
|
||||
scriptletDetails = super.retrieve(request, options);
|
||||
|
Loading…
Reference in New Issue
Block a user