Skip to content

Commit 1408422

Browse files
committed
Fine tune new reporting feature
Add ability to bring back logger button in popup panel through the advanced setting `uiPopupConfig`. Adding `+logger` token to `uiPopupConfig` will bring back the logger icon in the mobile version of the popup panel. Additionally, the link to the logger in the Support pane will take into account whether the <Shift> key is pressed, so as to behave like the logger icon in the popup panel. Related issue: - uBlockOrigin/uBlock-issues#1847 The troubleshooting information has been further fine-tuned to report popup panel data related to the reported page, for better diagnosis by disclosing any customization to uBO which was affecting the reported page.
1 parent 6f31f07 commit 1408422

File tree

6 files changed

+78
-76
lines changed

6 files changed

+78
-76
lines changed

src/css/popup-fenix.css

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,9 +580,14 @@ body.godMode #actionSelector > #dynaAllow {
580580
:root body[data-ui~="+no-popups"] #no-popups {
581581
display: flex;
582582
}
583-
:root.mobile [href="logger-ui.html#_"] {
583+
:root.mobile [href="logger-ui.html#_"],
584+
:root body[data-ui~="-logger"] [href="logger-ui.html#_"] {
584585
display: none;
585586
}
587+
:root:not(.mobile) [href="logger-ui.html#_"],
588+
:root body[data-ui~="+logger"] [href="logger-ui.html#_"] {
589+
display: flex;
590+
}
586591
body:not([data-more~="a"]) [data-more="a"],
587592
body:not([data-more~="b"]) [data-more="b"],
588593
body:not([data-more~="c"]) [data-more="c"],

src/css/support.css

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,28 @@ body {
55
.body > div {
66
max-width: 800px;
77
}
8-
8+
h3 {
9+
margin-bottom: 0;
10+
}
911
.supportEntry {
1012
display: flex;
11-
margin-top: 1em;
1213
}
1314
:root.mobile .supportEntry {
1415
flex-direction: column;
1516
}
1617
.supportEntry > div:first-of-type {
1718
flex-grow: 1;
1819
}
20+
:root:not(.mobile) .supportEntry > div:first-of-type {
21+
margin-inline-end: 2em;
22+
}
1923
.supportEntry > div.hasButtons {
2024
align-items: center;
2125
display: flex;
2226
justify-content: space-around;
2327
}
2428
.supportEntry h3 {
25-
margin-top: 0;
29+
margin: 1em 0;
2630
}
2731

2832
.e > .supportEntry {
@@ -45,8 +49,7 @@ body.filterIssue .body > div:not(.e) {
4549
}
4650

4751
button {
48-
margin-inline-end: 1em;
49-
-webkit-margin-end: 1em;
52+
align-self: center;
5053
}
5154
span[data-url] {
5255
color: var(--link-ink);

src/js/messaging.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,8 @@ const onMessage = function(request, sender, callback) {
490490
const pageStore = µb.pageStoreFromTabId(request.tabId);
491491
if ( pageStore === null ) { break; }
492492
const supportURL = new URL(vAPI.getURL('support.html'));
493-
supportURL.searchParams.set('reportURL', pageStore.rawURL);
493+
supportURL.searchParams.set('pageURL', request.pageURL);
494+
supportURL.searchParams.set('popupPanel', request.popupPanel);
494495
µb.openNewTab({ url: supportURL.href, select: true, index: -1 });
495496
break;
496497
}

src/js/popup-fenix.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,27 @@ const gotoPick = function() {
840840
/******************************************************************************/
841841

842842
const gotoReport = function() {
843+
const popupPanel = {
844+
blocked: popupData.pageCounts.blocked.any,
845+
};
846+
const reportedStates = [
847+
{ name: 'enabled', prop: 'netFilteringSwitch', expected: true },
848+
{ name: 'no-cosmetic-filtering', prop: 'noCosmeticFiltering', expected: false },
849+
{ name: 'no-large-media', prop: 'noLargeMedia', expected: false },
850+
{ name: 'no-popups', prop: 'noPopups', expected: false },
851+
{ name: 'no-remote-fonts', prop: 'noRemoteFonts', expected: false },
852+
{ name: 'no-scripting', prop: 'noScripting', expected: false },
853+
{ name: 'can-element-picker', prop: 'canElementPicker', expected: true },
854+
];
855+
for ( const { name, prop, expected } of reportedStates ) {
856+
if ( popupData[prop] === expected ) { continue; }
857+
popupPanel[name] = !expected;
858+
}
843859
messaging.send('popupPanel', {
844860
what: 'launchReporter',
845861
tabId: popupData.tabId,
862+
pageURL: popupData.pageURL,
863+
popupPanel: JSON.stringify(popupPanel),
846864
});
847865

848866
vAPI.closePopup();

src/js/support.js

Lines changed: 35 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ let supportData;
2929

3030
const uselessKeys = [
3131
'modifiedHiddenSettings.benchmarkDatasetURL',
32+
'modifiedHiddenSettings.consoleLogLevel',
33+
'modifiedHiddenSettings.uiPopupConfig',
3234
'modifiedUserSettings.alwaysDetachLogger',
3335
'modifiedUserSettings.popupPanelSections',
3436
'modifiedUserSettings.externalLists',
@@ -133,65 +135,43 @@ function showData() {
133135
const shownData = JSON.parse(JSON.stringify(supportData));
134136
uselessKeys.forEach(prop => { removeKey(shownData, prop); });
135137
const redacted = true;
136-
// If the report is for a specific site, report per-site switches which
137-
// are triggered on the reported site.
138-
if (
139-
reportHostname !== '' &&
140-
shownData.switchRuleset instanceof Object &&
141-
Array.isArray(shownData.switchRuleset.added)
142-
) {
143-
const added = [];
144-
const triggered = [];
145-
for ( const rule of shownData.switchRuleset.added ) {
146-
const match = /^[^:]+:\s+(\S+)/.exec(rule);
147-
if (
148-
match[1] === '*' ||
149-
reportHostname === match[1] ||
150-
reportHostname.endsWith(`.${match[1]}`)
151-
) {
152-
triggered.push(rule);
153-
} else {
154-
added.push(rule);
155-
}
156-
}
157-
if ( triggered.length !== 0 ) {
158-
shownData.switchRuleset.triggered = triggered;
159-
shownData.switchRuleset.added = added;
160-
}
161-
}
162138
if ( redacted ) {
163139
sensitiveValues.forEach(prop => { redactValue(shownData, prop); });
164140
sensitiveKeys.forEach(prop => { redactKeys(shownData, prop); });
165141
}
166142
for ( const prop in shownData ) {
167143
patchEmptiness(shownData, prop);
168144
}
145+
if ( reportedPage !== null ) {
146+
shownData.popupPanel = reportedPage.popupPanel;
147+
}
169148
const text = JSON.stringify(shownData, null, 2)
170149
.split('\n')
171150
.slice(1, -1)
172151
.map(v => {
173152
return v
174-
.replace( /^( *?) "/, '$1')
175-
.replace( /^( *.*[^\\])(?:": "|": \{$|": \[$|": )/, '$1: ')
176-
.replace( /(?:",?|\},?|\],?|,)$/, '');
153+
.replace(/^( *?) "/, '$1')
154+
.replace(/^( *.*[^\\])(?:": "|": \{$|": \[$|": )/, '$1: ')
155+
.replace(/(?:",?|\},?|\],?|,)$/, '');
177156
})
178157
.filter(v => v.trim() !== '')
179158
.join('\n') + '\n';
180159

181160
cmEditor.setValue(text);
182161
cmEditor.clearHistory();
183162

184-
addDetailsToReportURL('filterReport', redacted === false);
185-
addDetailsToReportURL('bugReport', redacted === false);
163+
addDetailsToReportURL('filterReport', true);
164+
addDetailsToReportURL('bugReport', true);
186165
}
187166

188167
/******************************************************************************/
189168

190-
const reportHostname = (( ) => {
169+
const reportedPage = (( ) => {
191170
const url = new URL(window.location.href);
192171
try {
193-
const reportURL = url.searchParams.get('reportURL');
194-
const parsedURL = new URL(reportURL);
172+
const pageURL = url.searchParams.get('pageURL');
173+
if ( pageURL === null ) { return null; }
174+
const parsedURL = new URL(pageURL);
195175
parsedURL.username = '';
196176
parsedURL.password = '';
197177
parsedURL.hash = '';
@@ -209,13 +189,14 @@ const reportHostname = (( ) => {
209189
option.textContent = parsedURL.href;
210190
select.append(option);
211191
}
212-
if ( reportURL !== null ) {
213-
document.body.classList.add('filterIssue');
214-
}
215-
return parsedURL.hostname.replace(/^www\./, '');
192+
document.body.classList.add('filterIssue');
193+
return {
194+
hostname: parsedURL.hostname.replace(/^www\./, ''),
195+
popupPanel: JSON.parse(url.searchParams.get('popupPanel')),
196+
};
216197
} catch(ex) {
217198
}
218-
return '';
199+
return null;
219200
})();
220201

221202
function reportSpecificFilterType() {
@@ -225,7 +206,7 @@ function reportSpecificFilterType() {
225206
function reportSpecificFilterIssue(ev) {
226207
const githubURL = new URL('https://github.com/uBlockOrigin/uAssets/issues/new?template=specific_report_from_ubo.yml');
227208
const issueType = reportSpecificFilterType();
228-
let title = `${reportHostname}: ${issueType}`;
209+
let title = `${reportedPage.hostname}: ${issueType}`;
229210
if ( document.getElementById('isNSFW').checked ) {
230211
title = `[nsfw] ${title}`;
231212
}
@@ -269,24 +250,26 @@ uBlockDashboard.patchCodeMirrorEditor(cmEditor);
269250
if ( typeof url !== 'string' || url === '' ) { return; }
270251
vAPI.messaging.send('default', {
271252
what: 'gotoURL',
272-
details: { url, select: true, index: -1 },
253+
details: { url, select: true, index: -1, shiftKey: ev.shiftKey },
273254
});
274255
ev.preventDefault();
275256
});
276257

277-
uDom('[data-i18n="supportReportSpecificButton"]').on('click', ev => {
278-
reportSpecificFilterIssue(ev);
279-
});
258+
if ( reportedPage !== null ) {
259+
uDom('[data-i18n="supportReportSpecificButton"]').on('click', ev => {
260+
reportSpecificFilterIssue(ev);
261+
});
280262

281-
uDom('[data-i18n="supportFindSpecificButton"]').on('click', ev => {
282-
const url = new URL('https://github.com/uBlockOrigin/uAssets/issues');
283-
url.searchParams.set('q', `is:issue "${reportHostname}" in:title`);
284-
vAPI.messaging.send('default', {
285-
what: 'gotoURL',
286-
details: { url: url.href, select: true, index: -1 },
263+
uDom('[data-i18n="supportFindSpecificButton"]').on('click', ev => {
264+
const url = new URL('https://github.com/uBlockOrigin/uAssets/issues');
265+
url.searchParams.set('q', `is:issue "${reportedPage.hostname}" in:title`);
266+
vAPI.messaging.send('default', {
267+
what: 'gotoURL',
268+
details: { url: url.href, select: true, index: -1 },
269+
});
270+
ev.preventDefault();
287271
});
288-
ev.preventDefault();
289-
});
272+
}
290273

291274
uDom('#selectAllButton').on('click', ( ) => {
292275
cmEditor.focus();

src/support.html

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,59 +18,51 @@
1818

1919
<div class="body">
2020
<div class="a">
21+
<h3 data-i18n="supportS1H"></h3>
2122
<div class="supportEntry">
2223
<div>
23-
<h3 data-i18n="supportS1H"></h3>
2424
<p data-i18n="supportS1P1">
2525
</div>
26-
<div>
27-
<button type="button" data-url="https://github.com/gorhill/uBlock/wiki" data-i18n="supportOpenButton"></button>
28-
</div>
26+
<button type="button" data-url="https://github.com/gorhill/uBlock/wiki" data-i18n="supportOpenButton"></button>
2927
</div>
3028
<hr>
3129
</div>
3230
<div class="b">
31+
<h3 data-i18n="supportS2H"></h3>
3332
<div class="supportEntry">
3433
<div>
35-
<h3 data-i18n="supportS2H"></h3>
3634
<p data-i18n="supportS2P1">
3735
</div>
38-
<div>
39-
<button type="button" data-url="https://old.reddit.com/r/uBlockOrigin/" data-i18n="supportOpenButton"></button>
40-
</div>
36+
<button type="button" data-url="https://old.reddit.com/r/uBlockOrigin/" data-i18n="supportOpenButton"></button>
4137
</div>
4238
<hr>
4339
</div>
4440
<div class="c">
41+
<h3 data-i18n="supportS3H"></h3>
4542
<div class="supportEntry">
4643
<div>
47-
<h3 data-i18n="supportS3H"></h3>
4844
<p data-i18n="supportS3P1">
4945
<p data-i18n="supportS3P2">
5046
<p data-i18n="supportS3P3">
5147
</div>
52-
<div>
53-
<button id="filterReport" type="button" data-url="https://github.com/uBlockOrigin/uAssets/issues/new?template=report_from_ubo.yml" data-i18n="supportOpenButton"></button>
54-
</div>
48+
<button id="filterReport" type="button" data-url="https://github.com/uBlockOrigin/uAssets/issues/new?template=report_from_ubo.yml" data-i18n="supportOpenButton"></button>
5549
</div>
5650
<hr>
5751
</div>
5852
<div class="d">
53+
<h3 data-i18n="supportS4H"></h3>
5954
<div class="supportEntry">
6055
<div>
61-
<h3 data-i18n="supportS4H"></h3>
6256
<p data-i18n="supportS4P1">
6357
</div>
64-
<div>
65-
<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>
66-
</div>
58+
<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>
6759
</div>
6860
<hr>
6961
</div>
7062
<div class="e">
63+
<h3 data-i18n="supportS6H"></h3>
7164
<div class="supportEntry">
7265
<div>
73-
<h3 data-i18n="supportS6H"></h3>
7466
<p data-i18n="supportS3P1">
7567
<p data-i18n="supportS6P1S1">
7668
<p>

0 commit comments

Comments
 (0)