From 730735cc5eff05faed63b2b3c5aee162edb3f2bb Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Fri, 15 Oct 2021 14:50:34 -0400 Subject: [PATCH] Further fine-tune new Support pane Related commit: - https://github.com/gorhill/uBlock/commit/a3a43c7cb43694d623476ecc1a9f2b646f740726 Specifically: - Support i18n - Autofill issues opened through Support pane with configuration information - Remove from About pane items found in Support pane --- src/_locales/en/messages.json | 82 ++++++++++++++++++++++++++++++----- src/about.html | 6 --- src/css/support.css | 4 ++ src/js/about.js | 7 --- src/js/messaging.js | 29 ++++--------- src/js/support.js | 67 ++++++++++++++++++++++++---- src/support.html | 35 +++++++-------- 7 files changed, 160 insertions(+), 70 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 808358f69..1a89f22ec 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -851,6 +851,72 @@ "message": "Markdown", "description": "Label for radio-button to pick export text format" }, + + "supportOpenButton": { + "message": "Open", + "description": "Text for button which open an external webpage in Support pane" + }, + "supportS1H": { + "message": "Documentation", + "description": "Header of 'Documentation' section in Support pane" + }, + "supportS1P1": { + "message": "Read the documentation at uBlock/wiki to learn about all of uBlock Origin's features.", + "description": "First paragraph of 'Documentation' section in Support pane" + }, + "supportS2H": { + "message": "Questions and support", + "description": "Header of 'Questions and support' section in Support pane" + }, + "supportS2P1": { + "message": "Answers to questions and other kinds of help support is provided on the subreddit /r/uBlockOrigin.", + "description": "First paragraph of 'Questions and support' section in Support pane" + }, + "supportS3H": { + "message": "Filter issues/website is broken", + "description": "Header of 'Filter issues' section in Support pane" + }, + "supportS3P1": { + "message": "Report filter issues with specific websites to uBlockOrigin/uAssets issue tracker. Requires a GitHub account.", + "description": "First paragraph of 'Filter issues' section in Support pane" + }, + "supportS3P2": { + "message": "Important: Avoid using other similarly-purposed blockers along with uBlock Origin, as this may cause filter issues on specific websites.", + "description": "Second paragraph of 'Filter issues' section in Support pane" + }, + "supportS3P3": { + "message": "Tips: Be sure your filter lists are up to date. The logger is the primary tool to diagnose filter-related issues.", + "description": "Third paragraph of 'Filter issues' section in Support pane" + }, + "supportS4H": { + "message": "Bug report", + "description": "Header of 'Bug report' section in Support pane" + }, + "supportS4P1": { + "message": "Report issues with uBlock Origin itself to uBlockOrigin/uBlock-issue issue tracker. Requires a GitHub account.", + "description": "First paragraph of 'Bug report' section in Support pane" + }, + "supportS5H": { + "message": "Troubleshooting Information", + "description": "Header of 'Troubleshooting Information' section in Support pane" + }, + "supportS5P1": { + "message": "Below is technical information that might be useful when volunteers are trying to help you solve a problem.", + "description": "First paragraph of 'Troubleshooting Information' section in Support pane" + }, + "supportS5P2": { + "message": "Important: Potentially private or sensitive information is redacted by default. Redacted information may make it more difficult to solve a problem.", + "description": "Second paragraph of 'Troubleshooting Information' section in Support pane" + }, + "supportRedact": { + "message": "Redact", + "description": "Text for 'Redact' button" + }, + "supportUnredact": { + "message": "Unredact", + "description": "Text for 'Unredact' button" + }, + "aboutPrivacyPolicy": { "message": "Privacy policy", "description": "Link to privacy policy on GitHub (English)" @@ -859,18 +925,6 @@ "message": "Changelog", "description": "" }, - "aboutWiki": { - "message": "Wiki", - "description": "English: project' wiki on GitHub" - }, - "aboutSupport": { - "message": "Support", - "description": "A link for where to get support" - }, - "aboutIssues": { - "message": "Issue tracker", - "description": "Text for a link to official issue tracker" - }, "aboutCode": { "message": "Source code (GPLv3)", "description": "English: Source code (GPLv3)" @@ -1079,6 +1133,10 @@ "message": "Copy to clipboard", "description": "Label for buttons used to copy something to the clipboard" }, + "genericSelectAll": { + "message": "Select all", + "description": "Label for buttons used to select all text in editor" + }, "toggleBlockingProfile": { "message": "Toggle blocking profile", "description": "Label for keyboard shortcut used to toggle blocking profile" diff --git a/src/about.html b/src/about.html index cc90df92d..f852e5324 100644 --- a/src/about.html +++ b/src/about.html @@ -19,12 +19,6 @@
-
-
-
-
-
-
diff --git a/src/css/support.css b/src/css/support.css index c264f157f..1d6f32f5a 100644 --- a/src/css/support.css +++ b/src/css/support.css @@ -21,6 +21,10 @@ button { margin-inline-end: 1em; -webkit-margin-end: 1em; } +span[data-url] { + color: var(--link-ink); + cursor: pointer; + } body.redacted #redactButton { display: none; diff --git a/src/js/about.js b/src/js/about.js index 385dce273..6317d09f8 100644 --- a/src/js/about.js +++ b/src/js/about.js @@ -26,13 +26,6 @@ /******************************************************************************/ (async ( ) => { - document.querySelector( - '[href="logger-ui.html"]' - ).addEventListener( - 'click', - self.uBlockDashboard.openOrSelectPage - ); - const appData = await vAPI.messaging.send('dashboard', { what: 'getAppData', }); diff --git a/src/js/messaging.js b/src/js/messaging.js index c174c7047..c44b6782b 100644 --- a/src/js/messaging.js +++ b/src/js/messaging.js @@ -1230,23 +1230,15 @@ const getSupportData = async function() { } }; - let modifiedUserSettings = µb.getModifiedSettings( + const modifiedUserSettings = µb.getModifiedSettings( µb.userSettings, µb.userSettingsDefault ); - delete modifiedUserSettings.externalLists; - delete modifiedUserSettings.importedLists; - if ( Object.keys(modifiedUserSettings).length === 0 ) { - modifiedUserSettings = 'none'; - } - let modifiedHiddenSettings = µb.getModifiedSettings( + const modifiedHiddenSettings = µb.getModifiedSettings( µb.hiddenSettings, µb.hiddenSettingsDefault ); - if ( Object.keys(modifiedHiddenSettings).length === 0 ) { - modifiedHiddenSettings = 'none'; - } let filterset = []; const userFilters = await µb.loadUserFilters(); @@ -1254,9 +1246,6 @@ const getSupportData = async function() { if ( /^($|![^#])/.test(line) ) { continue; } filterset.push(line); } - if ( filterset.length === 0 ) { - filterset = undefined; - } const lists = µb.availableFilterLists; let defaultListset = {}; @@ -1317,23 +1306,23 @@ const getSupportData = async function() { modifiedUserSettings, modifiedHiddenSettings, listset: { - 'default': defaultListset, - added: addedListset, removed: removedListset, + added: addedListset, + default: defaultListset, }, - filterset, trustedset: diffArrays( µb.arrayFromWhitelist(µb.netWhitelist), µb.netWhitelistDefault ), - hostRuleset: diffArrays( - sessionFirewall.toArray(), - µb.dynamicFilteringDefault - ), + filterset, switchRuleset: diffArrays( sessionSwitches.toArray(), µb.hostnameSwitchesDefault ), + hostRuleset: diffArrays( + sessionFirewall.toArray(), + µb.dynamicFilteringDefault + ), urlRuleset: diffArrays( sessionURLFiltering.toArray(), [] diff --git a/src/js/support.js b/src/js/support.js index 2cb12de83..4b051ca85 100644 --- a/src/js/support.js +++ b/src/js/support.js @@ -27,8 +27,15 @@ let supportData; +const uselessKeys = [ + 'modifiedUserSettings.popupPanelSections', + 'modifiedUserSettings.externalLists', + 'modifiedUserSettings.importedLists', +]; + const sensitiveValues = [ 'filterset', + 'modifiedUserSettings.popupPanelSections', 'modifiedHiddenSettings.userResourcesLocation', 'trustedset.added', 'hostRuleset.added', @@ -42,6 +49,16 @@ const sensitiveKeys = [ /******************************************************************************/ +function removeKey(data, prop) { + if ( data instanceof Object === false ) { return; } + const pos = prop.indexOf('.'); + if ( pos !== -1 ) { + const key = prop.slice(0, pos); + return removeKey(data[key], prop.slice(pos + 1)); + } + delete data[prop]; +} + function redactValue(data, prop) { if ( data instanceof Object === false ) { return; } const pos = prop.indexOf('.'); @@ -51,7 +68,11 @@ function redactValue(data, prop) { let value = data[prop]; if ( value === undefined ) { return; } if ( Array.isArray(value) ) { - value = `[array of ${value.length} redacted]`; + if ( value.length !== 0 ) { + value = `[array of ${value.length} redacted]`; + } else { + value = '[empty]'; + } } else { value = '[redacted]'; } @@ -76,14 +97,39 @@ function redactKeys(data, prop) { } } +function patchEmptiness(data, prop) { + const entry = data[prop]; + if ( Array.isArray(entry) && entry.length === 0 ) { + data[prop] = '[empty]'; + return; + } + if ( entry instanceof Object === false ) { return; } + if ( Object.keys(entry).length === 0 ) { + data[prop] = '[none]'; + return; + } + for ( const key in entry ) { + patchEmptiness(entry, key); + } +} + +function addDetailsToReportURL(id) { + const text = cmEditor.getValue(); + const elem = uDom.nodeFromId(id); + const url = new URL(elem.getAttribute('data-url')); + url.searchParams.set('configuration', `
\n\n${text}\n
`); + elem.setAttribute('data-url', url); +} + function showData() { const shownData = JSON.parse(JSON.stringify(supportData)); + uselessKeys.forEach(prop => { removeKey(shownData, prop); }); if ( document.body.classList.contains('redacted') ) { sensitiveValues.forEach(prop => { redactValue(shownData, prop); }); sensitiveKeys.forEach(prop => { redactKeys(shownData, prop); }); - - // Redact list entries which could be hosted locally - + } + for ( const prop in shownData ) { + patchEmptiness(shownData, prop); } const text = JSON.stringify(shownData, null, 2) .split('\n') @@ -95,9 +141,13 @@ function showData() { .replace( /(?:"|"|\}|\]),?$/, ''); }) .filter(v => v.trim() !== '') - .join('\n'); - cmEditor.setValue(text + '\n'); + .join('\n') + '\n'; + + cmEditor.setValue(text); cmEditor.clearHistory(); + + addDetailsToReportURL('filterReport'); + addDetailsToReportURL('bugReport'); } /******************************************************************************/ @@ -126,11 +176,12 @@ uBlockDashboard.patchCodeMirrorEditor(cmEditor); showData(); uDom('[data-url]').on('click', ev => { - const url = ev.target.getAttribute('data-url'); + const elem = ev.target.closest('[data-url]'); + const url = elem.getAttribute('data-url'); if ( typeof url !== 'string' || url === '' ) { return; } vAPI.messaging.send('default', { what: 'gotoURL', - details: { url, select: true }, + details: { url, select: true, index: -1 }, }); ev.preventDefault(); }); diff --git a/src/support.html b/src/support.html index ec5c94051..8e8886a1f 100644 --- a/src/support.html +++ b/src/support.html @@ -19,49 +19,50 @@
-

Documentation

-

Read the documentation to learn more about all of uBlock Origin's features. +

+

- +

-

Questions and support

-

Answers to questions and other kinds of help support is provided on the subreddit /r/uBlockOrigin. +

+

- +

-

Filter issues/website is broken

-

Report any issues with specific websites to uAssets issue tracker. -

Important: Avoid using other similarly-purposed blockers along with uBlock Origin, as this may cause filter issues on specific websites. -

Tip: The logger is the primary tool to diagnose filter-related issues. +

+

+

+

- +

-

Bug report

-

File a bug report. +

+

- +

-

Troubleshooting Information

-

Below is technical information that might be useful when volunteers are trying to help you solve a problem.

Important: You may want to redact private or sensitive information before posting to a public forum. Redacted information may make it more difficult to solve a problem. The information is redacted by default. -

+

+

+

+