1919 Home: https://github.com/gorhill/uBlock
2020*/
2121
22- import { runtime , sendMessage } from './ext.js' ;
22+ import { browser , runtime , sendMessage } from './ext.js' ;
2323
2424/******************************************************************************/
2525
@@ -49,7 +49,7 @@ function renderData(data, depth = 0) {
4949
5050/******************************************************************************/
5151
52- export async function getTroubleshootingInfo ( siteMode ) {
52+ export async function getTroubleshootingInfo ( details ) {
5353 const manifest = runtime . getManifest ( ) ;
5454 const [
5555 platformInfo ,
@@ -58,6 +58,8 @@ export async function getTroubleshootingInfo(siteMode) {
5858 defaultMode ,
5959 userRules ,
6060 consoleOutput ,
61+ showBlockedCount ,
62+ registeredScripts ,
6163 hasOmnipotence ,
6264 ] = await Promise . all ( [
6365 runtime . getPlatformInfo ( ) ,
@@ -66,9 +68,11 @@ export async function getTroubleshootingInfo(siteMode) {
6668 sendMessage ( { what : 'getDefaultFilteringMode' } ) ,
6769 sendMessage ( { what : 'getEffectiveUserRules' } ) ,
6870 sendMessage ( { what : 'getConsoleOutput' } ) ,
71+ sendMessage ( { what : 'getShowBlockedCount' } ) ,
72+ sendMessage ( { what : 'getRegisteredContentScripts' } ) ,
6973 sendMessage ( { what : 'hasBroadHostPermissions' } ) ,
7074 ] ) ;
71- const browser = ( ( ) => {
75+ const vendor = ( ( ) => {
7276 const extURL = runtime . getURL ( '' ) ;
7377 let agent = '' , version = '?' ;
7478 if ( extURL . startsWith ( 'moz-extension:' ) ) {
@@ -96,17 +100,26 @@ export async function getTroubleshootingInfo(siteMode) {
96100 } ) ( ) ;
97101 const modes = [ 'no filtering' , 'basic' , 'optimal' , 'complete' ] ;
98102 const filtering = { } ;
99- if ( siteMode ) {
100- filtering . site = `${ modes [ siteMode ] } `
103+ if ( details ?. siteMode ) {
104+ filtering . site = `${ modes [ details . siteMode ] } `
101105 }
102106 filtering . default = `${ modes [ defaultMode ] } ` ;
103107 const config = {
104108 name : manifest . name ,
105109 version : manifest . version ,
106- browser,
110+ browser : vendor ,
107111 filtering,
108112 permission : hasOmnipotence ? 'all' : 'ask' ,
109113 } ;
114+ if ( details ?. tabId ) {
115+ let badge = '?' ;
116+ if ( showBlockedCount ) {
117+ badge = await browser . action . getBadgeText ( { tabId : details . tabId } ) ;
118+ }
119+ if ( badge ) {
120+ config . badge = badge ;
121+ }
122+ }
110123 if ( userRules . length !== 0 ) {
111124 config [ 'user rules' ] = userRules . length ;
112125 }
@@ -121,8 +134,11 @@ export async function getTroubleshootingInfo(siteMode) {
121134 enabledRulesets . push ( `-${ id } ` ) ;
122135 }
123136 config . rulesets = enabledRulesets . sort ( ) ;
137+ if ( registeredScripts . length !== 0 ) {
138+ config . scripting = registeredScripts ;
139+ }
124140 if ( consoleOutput . length !== 0 ) {
125- config . console = siteMode
141+ config . console = details ?. siteMode
126142 ? consoleOutput . slice ( - 8 )
127143 : consoleOutput ;
128144 }
0 commit comments