mirror of
https://github.com/gorhill/uBlock.git
synced 2025-10-05 21:32:39 +02:00
[mv3] Improve details of troublshooting info
Also, avoid loading troubleshooting module in service worker as it's of use only as a user interface component.
This commit is contained in:
@@ -88,6 +88,7 @@ import {
|
||||
} from './ruleset-manager.js';
|
||||
|
||||
import {
|
||||
getConsoleOutput,
|
||||
getMatchedRules,
|
||||
isSideloaded,
|
||||
toggleDeveloperMode,
|
||||
@@ -96,7 +97,6 @@ import {
|
||||
} from './debug.js';
|
||||
|
||||
import { dnr } from './ext-compat.js';
|
||||
import { getTroubleshootingInfo } from './troubleshooting.js';
|
||||
import { registerInjectables } from './scripting-manager.js';
|
||||
import { toggleToolbarIcon } from './action.js';
|
||||
|
||||
@@ -325,6 +325,12 @@ function onMessage(request, sender, callback) {
|
||||
});
|
||||
return true;
|
||||
|
||||
case 'getEnabledRulesets':
|
||||
dnr.getEnabledRulesets().then(rulesets => {
|
||||
callback(rulesets);
|
||||
});
|
||||
return true;
|
||||
|
||||
case 'getRulesetDetails':
|
||||
getRulesetDetails().then(rulesetDetails => {
|
||||
callback(Array.from(rulesetDetails.values()));
|
||||
@@ -532,11 +538,9 @@ function onMessage(request, sender, callback) {
|
||||
});
|
||||
return true;
|
||||
|
||||
case 'getTroubleshootingInfo':
|
||||
getTroubleshootingInfo(request.siteMode).then(info => {
|
||||
callback(info);
|
||||
});
|
||||
return true;
|
||||
case 'getConsoleOutput':
|
||||
callback(getConsoleOutput());
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@@ -21,11 +21,8 @@
|
||||
|
||||
import { dom, qs$ } from './dom.js';
|
||||
import {
|
||||
localRead,
|
||||
localRemove,
|
||||
localWrite,
|
||||
localRead, localRemove, localWrite,
|
||||
runtime,
|
||||
sendMessage,
|
||||
webextFlavor,
|
||||
} from './ext.js';
|
||||
import { faIconsInit } from './fa-icons.js';
|
||||
@@ -60,7 +57,9 @@ localRead('dashboard.activePane').then(pane => {
|
||||
// Update troubleshooting on-demand
|
||||
const tsinfoObserver = new IntersectionObserver(entries => {
|
||||
if ( entries.every(a => a.isIntersecting === false) ) { return; }
|
||||
sendMessage({ what: 'getTroubleshootingInfo' }).then(config => {
|
||||
import('./troubleshooting.js').then(module => {
|
||||
return module.getTroubleshootingInfo();
|
||||
}).then(config => {
|
||||
qs$('[data-i18n="supportS5H"] + pre').textContent = config;
|
||||
});
|
||||
});
|
||||
|
@@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
import { dom, qs$ } from './dom.js';
|
||||
import { getTroubleshootingInfo } from './troubleshooting.js';
|
||||
import { sendMessage } from './ext.js';
|
||||
|
||||
/******************************************************************************/
|
||||
@@ -92,10 +93,7 @@ async function reportSpecificFilterIssue() {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
sendMessage({
|
||||
what: 'getTroubleshootingInfo',
|
||||
siteMode: reportedPage.mode,
|
||||
}).then(config => {
|
||||
getTroubleshootingInfo(reportedPage.mode).then(config => {
|
||||
qs$('[data-i18n="supportS5H"] + pre').textContent = config;
|
||||
|
||||
dom.on('[data-url]', 'click', ev => {
|
||||
|
@@ -19,11 +19,7 @@
|
||||
Home: https://github.com/gorhill/uBlock
|
||||
*/
|
||||
|
||||
import { dnr } from './ext-compat.js';
|
||||
import { getConsoleOutput } from './debug.js';
|
||||
import { getDefaultFilteringMode } from './mode-manager.js';
|
||||
import { getEffectiveUserRules } from './ruleset-manager.js';
|
||||
import { runtime } from './ext.js';
|
||||
import { runtime, sendMessage } from './ext.js';
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
@@ -57,36 +53,43 @@ export async function getTroubleshootingInfo(siteMode) {
|
||||
const manifest = runtime.getManifest();
|
||||
const [
|
||||
platformInfo,
|
||||
rulesets,
|
||||
defaultConfig,
|
||||
enabledRulesets,
|
||||
defaultMode,
|
||||
userRules,
|
||||
consoleOutput,
|
||||
] = await Promise.all([
|
||||
runtime.getPlatformInfo(),
|
||||
dnr.getEnabledRulesets(),
|
||||
getDefaultFilteringMode(),
|
||||
getEffectiveUserRules(),
|
||||
sendMessage({ what: 'getDefaultConfig' }),
|
||||
sendMessage({ what: 'getEnabledRulesets' }),
|
||||
sendMessage({ what: 'getDefaultFilteringMode' }),
|
||||
sendMessage({ what: 'getEffectiveUserRules' }),
|
||||
sendMessage({ what: 'getConsoleOutput' }),
|
||||
]);
|
||||
const browser = (( ) => {
|
||||
const extURL = runtime.getURL('');
|
||||
let agent = '';
|
||||
let agent = '', version = '?';
|
||||
if ( extURL.startsWith('moz-extension:') ) {
|
||||
agent = 'Firefox';
|
||||
const match = /\bFirefox\/(\d+\.\d+)\b/.exec(navigator.userAgent);
|
||||
version = match && match[1] || '?';
|
||||
} else if ( extURL.startsWith('safari-web-extension:') ) {
|
||||
agent = 'Safari';
|
||||
const match = /\bVersion\/(\d+\.\d+)\b/.exec(navigator.userAgent);
|
||||
version = match && match[1] || '?';
|
||||
} else if ( /\bEdg\/\b/.test(navigator.userAgent) ) {
|
||||
agent = 'Edge';
|
||||
const match = /\bEdg\/(\d+)\b/.exec(navigator.userAgent);
|
||||
version = match && match[1] || '?';
|
||||
} else {
|
||||
agent = 'Chrome';
|
||||
const match = /\bChrome\/(\d+)\b/.exec(navigator.userAgent);
|
||||
version = match && match[1] || '?';
|
||||
}
|
||||
if ( /\bMobile\b/.test(navigator.userAgent) ) {
|
||||
agent += ' Mobile';
|
||||
}
|
||||
const reVersion = new RegExp(`\\b${agent.slice(0,3)}[^/]*/(\\d+)`);
|
||||
const match = reVersion.exec(navigator.userAgent);
|
||||
if ( match ) {
|
||||
agent += ` ${match[1]}`;
|
||||
}
|
||||
agent += ` (${platformInfo.os})`
|
||||
agent += ` ${version} (${platformInfo.os})`
|
||||
return agent;
|
||||
})();
|
||||
const modes = [ 'no filtering', 'basic', 'optimal', 'complete' ];
|
||||
@@ -104,8 +107,17 @@ export async function getTroubleshootingInfo(siteMode) {
|
||||
if ( userRules.length !== 0 ) {
|
||||
config['user rules'] = userRules.length;
|
||||
}
|
||||
config.rulesets = rulesets;
|
||||
const consoleOutput = getConsoleOutput();
|
||||
const defaultRulesets = defaultConfig.rulesets;
|
||||
for ( let i = 0; i < enabledRulesets.length; i++ ) {
|
||||
const id = enabledRulesets[i];
|
||||
if ( defaultRulesets.includes(id) ) { continue; }
|
||||
enabledRulesets[i] = `+${id}`;
|
||||
}
|
||||
for ( const id of defaultRulesets ) {
|
||||
if ( enabledRulesets.includes(id) ) { continue; }
|
||||
enabledRulesets.push(`-${id}`);
|
||||
}
|
||||
config.rulesets = enabledRulesets.sort();
|
||||
if ( consoleOutput.length !== 0 ) {
|
||||
config.console = siteMode
|
||||
? consoleOutput.slice(-8)
|
||||
|
Reference in New Issue
Block a user