[mv3] Add to troubleshooting info

This commit is contained in:
Raymond Hill 2026-01-21 15:40:01 -05:00
parent f36dd3461b
commit c6de97ceb7
No known key found for this signature in database
GPG key ID: F5630CAE62A14316
6 changed files with 46 additions and 10 deletions

View file

@ -402,6 +402,10 @@ function onMessage(request, sender, callback) {
}); });
return true; return true;
case 'getShowBlockedCount':
callback(rulesetConfig.showBlockedCount);
break;
case 'setShowBlockedCount': case 'setShowBlockedCount':
rulesetConfig.showBlockedCount = request.state && true || false; rulesetConfig.showBlockedCount = request.state && true || false;
if ( canShowBlockedCount ) { if ( canShowBlockedCount ) {
@ -595,6 +599,12 @@ function onMessage(request, sender, callback) {
}); });
return true; return true;
case 'getRegisteredContentScripts':
scrmgr.getRegisteredContentScripts().then(ids => {
callback(ids);
});
return true;
case 'getConsoleOutput': case 'getConsoleOutput':
callback(getConsoleOutput()); callback(getConsoleOutput());
break; break;
@ -667,7 +677,7 @@ async function startSession() {
// Permissions may have been removed while the extension was disabled // Permissions may have been removed while the extension was disabled
const permissionsUpdated = await syncWithBrowserPermissions(); const permissionsUpdated = await syncWithBrowserPermissions();
if ( isNewVersion || permissionsUpdated ) { if ( isNewVersion || permissionsUpdated || isSideloaded ) {
registerInjectables(); registerInjectables();
} }

View file

@ -235,6 +235,7 @@ dom.on('#gotoReport', 'click', ev => {
} }
if ( url === undefined ) { return; } if ( url === undefined ) { return; }
const reportURL = new URL(runtime.getURL('/report.html')); const reportURL = new URL(runtime.getURL('/report.html'));
reportURL.searchParams.set('tabid', currentTab.id);
reportURL.searchParams.set('url', tabURL.href); reportURL.searchParams.set('url', tabURL.href);
reportURL.searchParams.set('mode', popupPanelData.level); reportURL.searchParams.set('mode', popupPanelData.level);
sendMessage({ sendMessage({

View file

@ -51,6 +51,7 @@ const reportedPage = (( ) => {
return { return {
hostname: parsedURL.hostname.replace(/^(m|mobile|www)\./, ''), hostname: parsedURL.hostname.replace(/^(m|mobile|www)\./, ''),
mode: url.searchParams.get('mode'), mode: url.searchParams.get('mode'),
tabId: parseInt(url.searchParams.get('tabid'), 10) || 0,
}; };
} catch { } catch {
} }
@ -93,7 +94,7 @@ async function reportSpecificFilterIssue() {
/******************************************************************************/ /******************************************************************************/
getTroubleshootingInfo(reportedPage.mode).then(config => { getTroubleshootingInfo(reportedPage).then(config => {
qs$('[data-i18n="supportS5H"] + pre').textContent = config; qs$('[data-i18n="supportS5H"] + pre').textContent = config;
dom.on('[data-url]', 'click', ev => { dom.on('[data-url]', 'click', ev => {

View file

@ -352,7 +352,7 @@ async function updateSessionRules() {
let ruleId = 1; let ruleId = 1;
for ( const rule of addRulesUnfiltered ) { for ( const rule of addRulesUnfiltered ) {
rule.id = ruleId++; rule.id = ruleId++;
if ( Boolean(rule?.condition.regexFilter) === false ) { continue; } if ( Boolean(rule.condition.regexFilter) === false ) { continue; }
regexCount += 1; regexCount += 1;
if ( regexCount < maxRegexCount ) { continue; } if ( regexCount < maxRegexCount ) { continue; }
rule.id = 0; rule.id = 0;

View file

@ -423,6 +423,14 @@ export async function registerInjectables() {
/******************************************************************************/ /******************************************************************************/
export async function getRegisteredContentScripts() {
const scripts = await browser.scripting.getRegisteredContentScripts()
.catch(( ) => []);
return scripts.map(a => a.id);
}
/******************************************************************************/
export async function onWakeupRun() { export async function onWakeupRun() {
const cleanupTime = await sessionRead('scripting.manager.cleanup.time') || 0; const cleanupTime = await sessionRead('scripting.manager.cleanup.time') || 0;
const now = Date.now(); const now = Date.now();

View file

@ -19,7 +19,7 @@
Home: https://github.com/gorhill/uBlock Home: https://github.com/gorhill/uBlock
*/ */
import { runtime, sendMessage } from './ext.js'; import { browser, runtime, sendMessage } from './ext.js';
/******************************************************************************/ /******************************************************************************/
@ -49,7 +49,7 @@ function renderData(data, depth = 0) {
/******************************************************************************/ /******************************************************************************/
export async function getTroubleshootingInfo(siteMode) { export async function getTroubleshootingInfo(details) {
const manifest = runtime.getManifest(); const manifest = runtime.getManifest();
const [ const [
platformInfo, platformInfo,
@ -58,6 +58,8 @@ export async function getTroubleshootingInfo(siteMode) {
defaultMode, defaultMode,
userRules, userRules,
consoleOutput, consoleOutput,
showBlockedCount,
registeredScripts,
hasOmnipotence, hasOmnipotence,
] = await Promise.all([ ] = await Promise.all([
runtime.getPlatformInfo(), runtime.getPlatformInfo(),
@ -66,9 +68,11 @@ export async function getTroubleshootingInfo(siteMode) {
sendMessage({ what: 'getDefaultFilteringMode' }), sendMessage({ what: 'getDefaultFilteringMode' }),
sendMessage({ what: 'getEffectiveUserRules' }), sendMessage({ what: 'getEffectiveUserRules' }),
sendMessage({ what: 'getConsoleOutput' }), sendMessage({ what: 'getConsoleOutput' }),
sendMessage({ what: 'getShowBlockedCount' }),
sendMessage({ what: 'getRegisteredContentScripts' }),
sendMessage({ what: 'hasBroadHostPermissions' }), sendMessage({ what: 'hasBroadHostPermissions' }),
]); ]);
const browser = (( ) => { const vendor = (( ) => {
const extURL = runtime.getURL(''); const extURL = runtime.getURL('');
let agent = '', version = '?'; let agent = '', version = '?';
if ( extURL.startsWith('moz-extension:') ) { if ( extURL.startsWith('moz-extension:') ) {
@ -96,17 +100,26 @@ export async function getTroubleshootingInfo(siteMode) {
})(); })();
const modes = [ 'no filtering', 'basic', 'optimal', 'complete' ]; const modes = [ 'no filtering', 'basic', 'optimal', 'complete' ];
const filtering = {}; const filtering = {};
if ( siteMode ) { if ( details?.siteMode ) {
filtering.site = `${modes[siteMode]}` filtering.site = `${modes[details.siteMode]}`
} }
filtering.default = `${modes[defaultMode]}`; filtering.default = `${modes[defaultMode]}`;
const config = { const config = {
name: manifest.name, name: manifest.name,
version: manifest.version, version: manifest.version,
browser, browser: vendor,
filtering, filtering,
permission: hasOmnipotence ? 'all' : 'ask', permission: hasOmnipotence ? 'all' : 'ask',
}; };
if ( details?.tabId ) {
let badge = '?';
if ( showBlockedCount ) {
badge = await browser.action.getBadgeText({ tabId: details.tabId });
}
if ( badge ) {
config.badge = badge;
}
}
if ( userRules.length !== 0 ) { if ( userRules.length !== 0 ) {
config['user rules'] = userRules.length; config['user rules'] = userRules.length;
} }
@ -121,8 +134,11 @@ export async function getTroubleshootingInfo(siteMode) {
enabledRulesets.push(`-${id}`); enabledRulesets.push(`-${id}`);
} }
config.rulesets = enabledRulesets.sort(); config.rulesets = enabledRulesets.sort();
if ( registeredScripts.length !== 0 ) {
config.scripting = registeredScripts;
}
if ( consoleOutput.length !== 0 ) { if ( consoleOutput.length !== 0 ) {
config.console = siteMode config.console = details?.siteMode
? consoleOutput.slice(-8) ? consoleOutput.slice(-8)
: consoleOutput; : consoleOutput;
} }