mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
[mv3] Add to troubleshooting info whether webext API calls failed
Related discussion: https://github.com/uBlockOrigin/uBOL-home/issues/327#issuecomment-2904240310
This commit is contained in:
parent
13886f728d
commit
2076d42239
2 changed files with 39 additions and 8 deletions
|
|
@ -19,10 +19,18 @@
|
|||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
import { dom, qs$ } from './dom.js';
|
||||
import {
|
||||
dom,
|
||||
qs$,
|
||||
} from './dom.js';
|
||||
|
||||
import {
|
||||
localRead,
|
||||
runtime,
|
||||
sendMessage,
|
||||
} from './ext.js';
|
||||
|
||||
import { dnr } from './ext-compat.js';
|
||||
import { runtime } from './ext.js';
|
||||
import { sendMessage } from './ext.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
|
|
@ -98,10 +106,14 @@ async function getConfigData() {
|
|||
platformInfo,
|
||||
rulesets,
|
||||
defaultMode,
|
||||
registerContentScriptsReason,
|
||||
unregisterContentScriptsReason,
|
||||
] = await Promise.all([
|
||||
runtime.getPlatformInfo(),
|
||||
dnr.getEnabledRulesets(),
|
||||
sendMessage({ what: 'getDefaultFilteringMode' }),
|
||||
localRead('$scripting.registerContentScripts'),
|
||||
localRead('$scripting.unregisterContentScripts'),
|
||||
]);
|
||||
const browser = (( ) => {
|
||||
const extURL = runtime.getURL('');
|
||||
|
|
@ -138,6 +150,12 @@ async function getConfigData() {
|
|||
},
|
||||
rulesets,
|
||||
};
|
||||
if ( registerContentScriptsReason !== undefined ) {
|
||||
config.registerContentScripts = registerContentScriptsReason;
|
||||
}
|
||||
if ( unregisterContentScriptsReason !== undefined ) {
|
||||
config.unregisterContentScripts = unregisterContentScriptsReason;
|
||||
}
|
||||
return renderData(config);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,12 @@
|
|||
|
||||
import * as ut from './utils.js';
|
||||
|
||||
import { browser } from './ext.js';
|
||||
import {
|
||||
browser,
|
||||
localRemove,
|
||||
localWrite,
|
||||
} from './ext.js';
|
||||
|
||||
import { fetchJSON } from './fetch.js';
|
||||
import { getEnabledRulesetsDetails } from './ruleset-manager.js';
|
||||
import { getFilteringModeDetails } from './mode-manager.js';
|
||||
|
|
@ -607,14 +612,22 @@ async function registerInjectables() {
|
|||
|
||||
if ( toRemove.length !== 0 ) {
|
||||
ubolLog(`Unregistered ${toRemove} content (css/js)`);
|
||||
await browser.scripting.unregisterContentScripts({ ids: toRemove })
|
||||
.catch(reason => { console.info(reason); });
|
||||
await browser.scripting.unregisterContentScripts({ ids: toRemove }).then(( ) => {
|
||||
localRemove('$scripting.unregisterContentScripts');
|
||||
}).catch(reason => {
|
||||
localWrite('$scripting.unregisterContentScripts', reason);
|
||||
console.info(reason);
|
||||
});
|
||||
}
|
||||
|
||||
if ( toAdd.length !== 0 ) {
|
||||
ubolLog(`Registered ${toAdd.map(v => v.id)} content (css/js)`);
|
||||
await browser.scripting.registerContentScripts(toAdd)
|
||||
.catch(reason => { console.info(reason); });
|
||||
await browser.scripting.registerContentScripts(toAdd).then(( ) => {
|
||||
localRemove('$scripting.registerContentScripts');
|
||||
}).catch(reason => {
|
||||
localWrite('$scripting.registerContentScripts', reason);
|
||||
console.info(reason);
|
||||
});
|
||||
}
|
||||
|
||||
registerInjectables.barrier = false;
|
||||
|
|
|
|||
Loading…
Reference in a new issue