mirror of
https://github.com/gorhill/uBlock.git
synced 2026-03-11 09:04:36 +00:00
[mv3] Add to troubleshooting info
This commit is contained in:
parent
f36dd3461b
commit
c6de97ceb7
6 changed files with 46 additions and 10 deletions
|
|
@ -402,6 +402,10 @@ function onMessage(request, sender, callback) {
|
|||
});
|
||||
return true;
|
||||
|
||||
case 'getShowBlockedCount':
|
||||
callback(rulesetConfig.showBlockedCount);
|
||||
break;
|
||||
|
||||
case 'setShowBlockedCount':
|
||||
rulesetConfig.showBlockedCount = request.state && true || false;
|
||||
if ( canShowBlockedCount ) {
|
||||
|
|
@ -595,6 +599,12 @@ function onMessage(request, sender, callback) {
|
|||
});
|
||||
return true;
|
||||
|
||||
case 'getRegisteredContentScripts':
|
||||
scrmgr.getRegisteredContentScripts().then(ids => {
|
||||
callback(ids);
|
||||
});
|
||||
return true;
|
||||
|
||||
case 'getConsoleOutput':
|
||||
callback(getConsoleOutput());
|
||||
break;
|
||||
|
|
@ -667,7 +677,7 @@ async function startSession() {
|
|||
// Permissions may have been removed while the extension was disabled
|
||||
const permissionsUpdated = await syncWithBrowserPermissions();
|
||||
|
||||
if ( isNewVersion || permissionsUpdated ) {
|
||||
if ( isNewVersion || permissionsUpdated || isSideloaded ) {
|
||||
registerInjectables();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -235,6 +235,7 @@ dom.on('#gotoReport', 'click', ev => {
|
|||
}
|
||||
if ( url === undefined ) { return; }
|
||||
const reportURL = new URL(runtime.getURL('/report.html'));
|
||||
reportURL.searchParams.set('tabid', currentTab.id);
|
||||
reportURL.searchParams.set('url', tabURL.href);
|
||||
reportURL.searchParams.set('mode', popupPanelData.level);
|
||||
sendMessage({
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ const reportedPage = (( ) => {
|
|||
return {
|
||||
hostname: parsedURL.hostname.replace(/^(m|mobile|www)\./, ''),
|
||||
mode: url.searchParams.get('mode'),
|
||||
tabId: parseInt(url.searchParams.get('tabid'), 10) || 0,
|
||||
};
|
||||
} catch {
|
||||
}
|
||||
|
|
@ -93,7 +94,7 @@ async function reportSpecificFilterIssue() {
|
|||
|
||||
/******************************************************************************/
|
||||
|
||||
getTroubleshootingInfo(reportedPage.mode).then(config => {
|
||||
getTroubleshootingInfo(reportedPage).then(config => {
|
||||
qs$('[data-i18n="supportS5H"] + pre').textContent = config;
|
||||
|
||||
dom.on('[data-url]', 'click', ev => {
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ async function updateSessionRules() {
|
|||
let ruleId = 1;
|
||||
for ( const rule of addRulesUnfiltered ) {
|
||||
rule.id = ruleId++;
|
||||
if ( Boolean(rule?.condition.regexFilter) === false ) { continue; }
|
||||
if ( Boolean(rule.condition.regexFilter) === false ) { continue; }
|
||||
regexCount += 1;
|
||||
if ( regexCount < maxRegexCount ) { continue; }
|
||||
rule.id = 0;
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
const cleanupTime = await sessionRead('scripting.manager.cleanup.time') || 0;
|
||||
const now = Date.now();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
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 [
|
||||
platformInfo,
|
||||
|
|
@ -58,6 +58,8 @@ export async function getTroubleshootingInfo(siteMode) {
|
|||
defaultMode,
|
||||
userRules,
|
||||
consoleOutput,
|
||||
showBlockedCount,
|
||||
registeredScripts,
|
||||
hasOmnipotence,
|
||||
] = await Promise.all([
|
||||
runtime.getPlatformInfo(),
|
||||
|
|
@ -66,9 +68,11 @@ export async function getTroubleshootingInfo(siteMode) {
|
|||
sendMessage({ what: 'getDefaultFilteringMode' }),
|
||||
sendMessage({ what: 'getEffectiveUserRules' }),
|
||||
sendMessage({ what: 'getConsoleOutput' }),
|
||||
sendMessage({ what: 'getShowBlockedCount' }),
|
||||
sendMessage({ what: 'getRegisteredContentScripts' }),
|
||||
sendMessage({ what: 'hasBroadHostPermissions' }),
|
||||
]);
|
||||
const browser = (( ) => {
|
||||
const vendor = (( ) => {
|
||||
const extURL = runtime.getURL('');
|
||||
let agent = '', version = '?';
|
||||
if ( extURL.startsWith('moz-extension:') ) {
|
||||
|
|
@ -96,17 +100,26 @@ export async function getTroubleshootingInfo(siteMode) {
|
|||
})();
|
||||
const modes = [ 'no filtering', 'basic', 'optimal', 'complete' ];
|
||||
const filtering = {};
|
||||
if ( siteMode ) {
|
||||
filtering.site = `${modes[siteMode]}`
|
||||
if ( details?.siteMode ) {
|
||||
filtering.site = `${modes[details.siteMode]}`
|
||||
}
|
||||
filtering.default = `${modes[defaultMode]}`;
|
||||
const config = {
|
||||
name: manifest.name,
|
||||
version: manifest.version,
|
||||
browser,
|
||||
browser: vendor,
|
||||
filtering,
|
||||
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 ) {
|
||||
config['user rules'] = userRules.length;
|
||||
}
|
||||
|
|
@ -121,8 +134,11 @@ export async function getTroubleshootingInfo(siteMode) {
|
|||
enabledRulesets.push(`-${id}`);
|
||||
}
|
||||
config.rulesets = enabledRulesets.sort();
|
||||
if ( registeredScripts.length !== 0 ) {
|
||||
config.scripting = registeredScripts;
|
||||
}
|
||||
if ( consoleOutput.length !== 0 ) {
|
||||
config.console = siteMode
|
||||
config.console = details?.siteMode
|
||||
? consoleOutput.slice(-8)
|
||||
: consoleOutput;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue