1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-08 12:57:57 +02:00

Add informative tooltip re. unprocessed requests at launch

Related issue:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2585
This commit is contained in:
Raymond Hill 2023-04-09 14:02:01 -04:00
parent c5d62d9ae7
commit 3530b9dc89
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 12 additions and 10 deletions

View File

@ -731,9 +731,8 @@ if ( webext.browserAction instanceof Object ) {
{ {
const browserAction = vAPI.browserAction; const browserAction = vAPI.browserAction;
const titleTemplate = const titleTemplate = `${browser.runtime.getManifest().browser_action.default_title} ({badge})`;
browser.runtime.getManifest().browser_action.default_title + const browserLaunchIssue = browser.i18n.getMessage('unprocessedRequestTooltip');
' ({badge})';
const icons = [ const icons = [
{ path: { { path: {
'16': 'img/icon_16-off.png', '16': 'img/icon_16-off.png',
@ -840,8 +839,9 @@ if ( webext.browserAction instanceof Object ) {
const tab = await vAPI.tabs.get(tabId); const tab = await vAPI.tabs.get(tabId);
if ( tab === null ) { return; } if ( tab === null ) { return; }
const hasUnprocessedRequest = vAPI.net && vAPI.net.hasUnprocessedRequest(tabId);
const { parts, state } = details; const { parts, state } = details;
const { badge, color } = vAPI.net && vAPI.net.hasUnprocessedRequest(tabId) const { badge, color } = hasUnprocessedRequest
? { badge: '!', color: '#FC0' } ? { badge: '!', color: '#FC0' }
: details; : details;
@ -866,13 +866,11 @@ if ( webext.browserAction instanceof Object ) {
// - the platform does not support browserAction.setIcon(); OR // - the platform does not support browserAction.setIcon(); OR
// - the rendering of the badge is disabled // - the rendering of the badge is disabled
if ( browserAction.setTitle !== undefined ) { if ( browserAction.setTitle !== undefined ) {
browserAction.setTitle({ const title = hasUnprocessedRequest && browserLaunchIssue ||
tabId: tab.id, titleTemplate.replace('{badge}',
title: titleTemplate.replace(
'{badge}',
state === 1 ? (badge !== '' ? badge : '0') : 'off' state === 1 ? (badge !== '' ? badge : '0') : 'off'
) );
}); browserAction.setTitle({ tabId: tab.id, title });
} }
if ( vAPI.contextMenu instanceof Object ) { if ( vAPI.contextMenu instanceof Object ) {

View File

@ -1269,6 +1269,10 @@
"message": "Errors: {{count}}", "message": "Errors: {{count}}",
"description": "Summary of number of errors as reported by the linter " "description": "Summary of number of errors as reported by the linter "
}, },
"unprocessedRequestTooltip": {
"message": "Could not filter properly at browser launch.\nReload the page to ensure proper filtering",
"description": "Tooltip for the toolbar icon. Use newline character(s) where appropriate to prevent tooltip from being too long horizontally"
},
"dummy": { "dummy": {
"message": "This entry must be the last one", "message": "This entry must be the last one",
"description": "so we dont need to deal with comma for last entry" "description": "so we dont need to deal with comma for last entry"