mirror of
https://github.com/gorhill/uBlock.git
synced 2024-07-19 19:52:51 +02:00
Improve rendering of troubleshooting info
This commit is contained in:
parent
f116392b93
commit
2e465d48c0
@ -1527,8 +1527,8 @@ const getSupportData = async function() {
|
|||||||
sessionURLFiltering.toArray(),
|
sessionURLFiltering.toArray(),
|
||||||
[]
|
[]
|
||||||
),
|
),
|
||||||
modifiedUserSettings,
|
'userSettings': modifiedUserSettings,
|
||||||
modifiedHiddenSettings,
|
'hiddenSettings': modifiedHiddenSettings,
|
||||||
supportStats: µb.supportStats,
|
supportStats: µb.supportStats,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -28,24 +28,24 @@ import { dom, qs$ } from './dom.js';
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
const uselessKeys = [
|
const uselessKeys = [
|
||||||
'modifiedHiddenSettings.benchmarkDatasetURL',
|
'hiddenSettings.benchmarkDatasetURL',
|
||||||
'modifiedHiddenSettings.blockingProfiles',
|
'hiddenSettings.blockingProfiles',
|
||||||
'modifiedHiddenSettings.consoleLogLevel',
|
'hiddenSettings.consoleLogLevel',
|
||||||
'modifiedHiddenSettings.uiPopupConfig',
|
'hiddenSettings.uiPopupConfig',
|
||||||
'modifiedUserSettings.alwaysDetachLogger',
|
'userSettings.alwaysDetachLogger',
|
||||||
'modifiedUserSettings.firewallPaneMinimized',
|
'userSettings.firewallPaneMinimized',
|
||||||
'modifiedUserSettings.externalLists',
|
'userSettings.externalLists',
|
||||||
'modifiedUserSettings.importedLists',
|
'userSettings.importedLists',
|
||||||
'modifiedUserSettings.popupPanelSections',
|
'userSettings.popupPanelSections',
|
||||||
'modifiedUserSettings.uiAccentCustom',
|
'userSettings.uiAccentCustom',
|
||||||
'modifiedUserSettings.uiAccentCustom0',
|
'userSettings.uiAccentCustom0',
|
||||||
'modifiedUserSettings.uiTheme',
|
'userSettings.uiTheme',
|
||||||
];
|
];
|
||||||
|
|
||||||
const sensitiveValues = [
|
const sensitiveValues = [
|
||||||
'filterset (user)',
|
'filterset (user)',
|
||||||
'modifiedUserSettings.popupPanelSections',
|
'userSettings.popupPanelSections',
|
||||||
'modifiedHiddenSettings.userResourcesLocation',
|
'hiddenSettings.userResourcesLocation',
|
||||||
'trustedset.added',
|
'trustedset.added',
|
||||||
'hostRuleset.added',
|
'hostRuleset.added',
|
||||||
'switchRuleset.added',
|
'switchRuleset.added',
|
||||||
@ -136,6 +136,30 @@ function addDetailsToReportURL(id, collapse = false) {
|
|||||||
dom.attr(elem, 'data-url', url);
|
dom.attr(elem, 'data-url', url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderData(data, depth = 0) {
|
||||||
|
const indent = ' '.repeat(depth);
|
||||||
|
if ( Array.isArray(data) ) {
|
||||||
|
const out = [];
|
||||||
|
for ( const value of data ) {
|
||||||
|
out.push(renderData(value, depth));
|
||||||
|
}
|
||||||
|
return out.join('\n');
|
||||||
|
}
|
||||||
|
if ( typeof data !== 'object' ) {
|
||||||
|
return `${indent}${data}`;
|
||||||
|
}
|
||||||
|
const out = [];
|
||||||
|
for ( const [ name, value ] of Object.entries(data) ) {
|
||||||
|
if ( typeof value === 'object' ) {
|
||||||
|
out.push(`${indent}${name}:`);
|
||||||
|
out.push(renderData(value, depth + 1));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out.push(`${indent}${name}: ${value}`);
|
||||||
|
}
|
||||||
|
return out.join('\n');
|
||||||
|
}
|
||||||
|
|
||||||
async function showSupportData() {
|
async function showSupportData() {
|
||||||
const supportData = await vAPI.messaging.send('dashboard', {
|
const supportData = await vAPI.messaging.send('dashboard', {
|
||||||
what: 'getSupportData',
|
what: 'getSupportData',
|
||||||
@ -153,18 +177,7 @@ async function showSupportData() {
|
|||||||
if ( reportedPage !== null ) {
|
if ( reportedPage !== null ) {
|
||||||
shownData.popupPanel = reportedPage.popupPanel;
|
shownData.popupPanel = reportedPage.popupPanel;
|
||||||
}
|
}
|
||||||
const text = JSON.stringify(shownData, null, 1)
|
const text = renderData(shownData);
|
||||||
.split('\n')
|
|
||||||
.slice(1, -1)
|
|
||||||
.map(v => {
|
|
||||||
return v
|
|
||||||
.replace(/^( *?) "/, '$1')
|
|
||||||
.replace(/^( *.*[^\\])(?:": "|": \{$|": \[$|": )/, '$1: ')
|
|
||||||
.replace(/(?:",?|\},?|\],?|,)$/, '');
|
|
||||||
})
|
|
||||||
.filter(v => v.trim() !== '')
|
|
||||||
.join('\n') + '\n';
|
|
||||||
|
|
||||||
cmEditor.setValue(text);
|
cmEditor.setValue(text);
|
||||||
cmEditor.clearHistory();
|
cmEditor.clearHistory();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user