From 9637ab56a938460fe18a2217217e4eb4bdca5b28 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 23 Jan 2020 09:16:09 -0500 Subject: [PATCH] Insert icon badge text in icon title only if needed This is to fix the rendering of the menu entry in Firefox Fenix, which displays both the icon title and badge text as a menu entry: Before the fix: uBlock Origin (76) 76 After the fix: uBlock Origin 76 The badge text will still be part of the icon title when the icon badge is disabled by the user or when the platform does not supprt browserAction.setIcon() (as is the case on current Firefox for Android). --- platform/chromium/vapi-background.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index fd13d8b9c..fd4f027a7 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -824,7 +824,14 @@ vAPI.setIcon = (( ) => { } } - if ( browserAction.setTitle !== undefined ) { + // Insert the badge text in the title if: + // - the platform does not support browserAction.setIcon(); OR + // - the rendering of the badge is disabled + if ( + browserAction.setTitle !== undefined && ( + browserAction.setIcon === undefined || (parts & 0b1000) !== 0 + ) + ) { browserAction.setTitle({ tabId: tab.id, title: titleTemplate.replace(