1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-07 03:12:33 +01:00

Further fine-tune new Support pane

Related commit:
- a3a43c7cb4

Specifically:
- Support i18n
- Autofill issues opened through Support pane with configuration
  information
- Remove from About pane items found in Support pane
This commit is contained in:
Raymond Hill 2021-10-15 14:50:34 -04:00
parent 2c7fcf7284
commit 730735cc5e
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
7 changed files with 160 additions and 70 deletions

View File

@ -851,6 +851,72 @@
"message": "Markdown", "message": "Markdown",
"description": "Label for radio-button to pick export text format" "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 <code>uBlock/wiki</code> 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 <code>/r/uBlockOrigin</code>.",
"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 <span data-url=\"https://github.com/uBlockOrigin/uAssets/issues?q=is%3Aissue\"><code>uBlockOrigin/uAssets</code> issue tracker</span>. Requires a GitHub account.",
"description": "First paragraph of 'Filter issues' section in Support pane"
},
"supportS3P2": {
"message": "<b>Important:</b> 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": "<b>Tips:</b> Be sure your filter lists are up to date. <span data-url=\"logger-ui.html#_\">The logger</span> 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 <span data-url=\"https://github.com/uBlockOrigin/uBlock-issues/issues?q=is%3Aissue\"><code>uBlockOrigin/uBlock-issue</code> issue tracker</span>. 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": "<b>Important:</b> 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": { "aboutPrivacyPolicy": {
"message": "Privacy policy", "message": "Privacy policy",
"description": "Link to privacy policy on GitHub (English)" "description": "Link to privacy policy on GitHub (English)"
@ -859,18 +925,6 @@
"message": "Changelog", "message": "Changelog",
"description": "" "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": { "aboutCode": {
"message": "Source code (GPLv3)", "message": "Source code (GPLv3)",
"description": "English: Source code (GPLv3)" "description": "English: Source code (GPLv3)"
@ -1079,6 +1133,10 @@
"message": "Copy to clipboard", "message": "Copy to clipboard",
"description": "Label for buttons used to copy something to the 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": { "toggleBlockingProfile": {
"message": "Toggle blocking profile", "message": "Toggle blocking profile",
"description": "Label for keyboard shortcut used to toggle blocking profile" "description": "Label for keyboard shortcut used to toggle blocking profile"

View File

@ -19,12 +19,6 @@
</div> </div>
<div class="li"><a href="https://github.com/gorhill/uBlock/wiki/Privacy-policy" data-i18n="aboutPrivacyPolicy"></a></div> <div class="li"><a href="https://github.com/gorhill/uBlock/wiki/Privacy-policy" data-i18n="aboutPrivacyPolicy"></a></div>
<div class="li"><a href="https://github.com/gorhill/uBlock/releases" data-i18n="aboutChangelog"></a></div> <div class="li"><a href="https://github.com/gorhill/uBlock/releases" data-i18n="aboutChangelog"></a></div>
<div class="li"><a href="https://github.com/gorhill/uBlock/wiki" data-i18n="aboutWiki"></a></div>
<div class="li"><a href="https://old.reddit.com/r/uBlockOrigin/" data-i18n="aboutSupport"></a></div>
<div class="liul">
<div class="li"><a href="logger-ui.html" data-i18n="popupTipLog"></a></div>
</div>
<div class="li"><a href="https://github.com/uBlockOrigin/uBlock-issues/issues" data-i18n="aboutIssues"></a></div>
<div class="li"><a href="https://github.com/gorhill/uBlock" data-i18n="aboutCode"></a></div> <div class="li"><a href="https://github.com/gorhill/uBlock" data-i18n="aboutCode"></a></div>
<div class="li"><span data-i18n="aboutContributors"></span></div> <div class="li"><span data-i18n="aboutContributors"></span></div>
<div class="liul"> <div class="liul">

View File

@ -21,6 +21,10 @@ button {
margin-inline-end: 1em; margin-inline-end: 1em;
-webkit-margin-end: 1em; -webkit-margin-end: 1em;
} }
span[data-url] {
color: var(--link-ink);
cursor: pointer;
}
body.redacted #redactButton { body.redacted #redactButton {
display: none; display: none;

View File

@ -26,13 +26,6 @@
/******************************************************************************/ /******************************************************************************/
(async ( ) => { (async ( ) => {
document.querySelector(
'[href="logger-ui.html"]'
).addEventListener(
'click',
self.uBlockDashboard.openOrSelectPage
);
const appData = await vAPI.messaging.send('dashboard', { const appData = await vAPI.messaging.send('dashboard', {
what: 'getAppData', what: 'getAppData',
}); });

View File

@ -1230,23 +1230,15 @@ const getSupportData = async function() {
} }
}; };
let modifiedUserSettings = µb.getModifiedSettings( const modifiedUserSettings = µb.getModifiedSettings(
µb.userSettings, µb.userSettings,
µb.userSettingsDefault µ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.hiddenSettings,
µb.hiddenSettingsDefault µb.hiddenSettingsDefault
); );
if ( Object.keys(modifiedHiddenSettings).length === 0 ) {
modifiedHiddenSettings = 'none';
}
let filterset = []; let filterset = [];
const userFilters = await µb.loadUserFilters(); const userFilters = await µb.loadUserFilters();
@ -1254,9 +1246,6 @@ const getSupportData = async function() {
if ( /^($|![^#])/.test(line) ) { continue; } if ( /^($|![^#])/.test(line) ) { continue; }
filterset.push(line); filterset.push(line);
} }
if ( filterset.length === 0 ) {
filterset = undefined;
}
const lists = µb.availableFilterLists; const lists = µb.availableFilterLists;
let defaultListset = {}; let defaultListset = {};
@ -1317,23 +1306,23 @@ const getSupportData = async function() {
modifiedUserSettings, modifiedUserSettings,
modifiedHiddenSettings, modifiedHiddenSettings,
listset: { listset: {
'default': defaultListset,
added: addedListset,
removed: removedListset, removed: removedListset,
added: addedListset,
default: defaultListset,
}, },
filterset,
trustedset: diffArrays( trustedset: diffArrays(
µb.arrayFromWhitelist(µb.netWhitelist), µb.arrayFromWhitelist(µb.netWhitelist),
µb.netWhitelistDefault µb.netWhitelistDefault
), ),
hostRuleset: diffArrays( filterset,
sessionFirewall.toArray(),
µb.dynamicFilteringDefault
),
switchRuleset: diffArrays( switchRuleset: diffArrays(
sessionSwitches.toArray(), sessionSwitches.toArray(),
µb.hostnameSwitchesDefault µb.hostnameSwitchesDefault
), ),
hostRuleset: diffArrays(
sessionFirewall.toArray(),
µb.dynamicFilteringDefault
),
urlRuleset: diffArrays( urlRuleset: diffArrays(
sessionURLFiltering.toArray(), sessionURLFiltering.toArray(),
[] []

View File

@ -27,8 +27,15 @@
let supportData; let supportData;
const uselessKeys = [
'modifiedUserSettings.popupPanelSections',
'modifiedUserSettings.externalLists',
'modifiedUserSettings.importedLists',
];
const sensitiveValues = [ const sensitiveValues = [
'filterset', 'filterset',
'modifiedUserSettings.popupPanelSections',
'modifiedHiddenSettings.userResourcesLocation', 'modifiedHiddenSettings.userResourcesLocation',
'trustedset.added', 'trustedset.added',
'hostRuleset.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) { function redactValue(data, prop) {
if ( data instanceof Object === false ) { return; } if ( data instanceof Object === false ) { return; }
const pos = prop.indexOf('.'); const pos = prop.indexOf('.');
@ -51,7 +68,11 @@ function redactValue(data, prop) {
let value = data[prop]; let value = data[prop];
if ( value === undefined ) { return; } if ( value === undefined ) { return; }
if ( Array.isArray(value) ) { if ( Array.isArray(value) ) {
if ( value.length !== 0 ) {
value = `[array of ${value.length} redacted]`; value = `[array of ${value.length} redacted]`;
} else {
value = '[empty]';
}
} else { } else {
value = '[redacted]'; 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', `<details>\n\n${text}\n</details>`);
elem.setAttribute('data-url', url);
}
function showData() { function showData() {
const shownData = JSON.parse(JSON.stringify(supportData)); const shownData = JSON.parse(JSON.stringify(supportData));
uselessKeys.forEach(prop => { removeKey(shownData, prop); });
if ( document.body.classList.contains('redacted') ) { if ( document.body.classList.contains('redacted') ) {
sensitiveValues.forEach(prop => { redactValue(shownData, prop); }); sensitiveValues.forEach(prop => { redactValue(shownData, prop); });
sensitiveKeys.forEach(prop => { redactKeys(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) const text = JSON.stringify(shownData, null, 2)
.split('\n') .split('\n')
@ -95,9 +141,13 @@ function showData() {
.replace( /(?:"|"|\}|\]),?$/, ''); .replace( /(?:"|"|\}|\]),?$/, '');
}) })
.filter(v => v.trim() !== '') .filter(v => v.trim() !== '')
.join('\n'); .join('\n') + '\n';
cmEditor.setValue(text + '\n');
cmEditor.setValue(text);
cmEditor.clearHistory(); cmEditor.clearHistory();
addDetailsToReportURL('filterReport');
addDetailsToReportURL('bugReport');
} }
/******************************************************************************/ /******************************************************************************/
@ -126,11 +176,12 @@ uBlockDashboard.patchCodeMirrorEditor(cmEditor);
showData(); showData();
uDom('[data-url]').on('click', ev => { 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; } if ( typeof url !== 'string' || url === '' ) { return; }
vAPI.messaging.send('default', { vAPI.messaging.send('default', {
what: 'gotoURL', what: 'gotoURL',
details: { url, select: true }, details: { url, select: true, index: -1 },
}); });
ev.preventDefault(); ev.preventDefault();
}); });

View File

@ -19,49 +19,50 @@
<div class="body"> <div class="body">
<div class="supportEntry"> <div class="supportEntry">
<div> <div>
<h3>Documentation</h3> <h3 data-i18n="supportS1H"></h3>
<p>Read the documentation to learn more about all of uBlock Origin's features. <p data-i18n="supportS1P1">
</div> </div>
<div> <div>
<button type="button" data-url="https://github.com/gorhill/uBlock/wiki">Open</button> <button type="button" data-url="https://github.com/gorhill/uBlock/wiki" data-i18n="supportOpenButton"></button>
</div> </div>
</div> </div>
<hr> <hr>
<div class="supportEntry"> <div class="supportEntry">
<div> <div>
<h3>Questions and support</h3> <h3 data-i18n="supportS2H"></h3>
<p>Answers to questions and other kinds of help support is provided on the subreddit /r/uBlockOrigin. <p data-i18n="supportS2P1">
</div> </div>
<div> <div>
<button type="button" data-url="https://old.reddit.com/r/uBlockOrigin/">Open</button> <button type="button" data-url="https://old.reddit.com/r/uBlockOrigin/" data-i18n="supportOpenButton"></button>
</div> </div>
</div> </div>
<hr> <hr>
<div class="supportEntry"> <div class="supportEntry">
<div> <div>
<h3>Filter issues/website is broken</h3> <h3 data-i18n="supportS3H"></h3>
<p>Report any issues with specific websites to uAssets issue tracker. <p data-i18n="supportS3P1">
<p><b>Important:</b> Avoid using other similarly-purposed blockers along with uBlock Origin, as this may cause filter issues on specific websites. <p data-i18n="supportS3P2">
<p><b>Tip:</b> <a href="#" data-url="logger-ui.html">The logger</a> is the primary tool to diagnose filter-related issues. <p data-i18n="supportS3P3">
</div> </div>
<div> <div>
<button type="button" data-url="https://github.com/uBlockOrigin/uAssets/issues">Open</button> <button id="filterReport" type="button" data-url="https://github.com/uBlockOrigin/uAssets/issues/new?template=bug_report_from_ubo.yml" data-i18n="supportOpenButton"></button>
</div> </div>
</div> </div>
<hr> <hr>
<div class="supportEntry"> <div class="supportEntry">
<div> <div>
<h3>Bug report</h3> <h3 data-i18n="supportS4H"></h3>
<p>File a bug report. <p data-i18n="supportS4P1">
</div> </div>
<div> <div>
<button type="button" data-url="https://github.com/uBlockOrigin/uBlock-issues/issues/new?template=bug_report.yml">Open</button> <button id="bugReport" type="button" data-url="https://github.com/uBlockOrigin/uBlock-issues/issues/new?template=bug_report_from_ubo.yml" data-i18n="supportOpenButton"></button>
</div> </div>
</div> </div>
<hr> <hr>
<h3>Troubleshooting Information</h3> <h3 data-i18n="supportS5H"></h3>
<p>Below is technical information that might be useful when volunteers are trying to help you solve a problem. <p><b>Important:</b> 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. <p data-i18n="supportS5P1">
<p><button id="redactButton" type="button">Redact</button><button id="unredactButton" type="button">Unredact</button><button id="selectAllButton" type="button">Select all</button> <p data-i18n="supportS5P2">
<p><button id="redactButton" type="button" data-i18n="supportRedact"></button><button id="unredactButton" type="button" data-i18n="supportUnredact"></button><button id="selectAllButton" type="button" data-i18n="genericSelectAll"></button>
<div id="supportData" class="codeMirrorContainer"></div> <div id="supportData" class="codeMirrorContainer"></div>
</div> </div>