From 9a65fe5527d725adc0d944d39c545098b34bcf70 Mon Sep 17 00:00:00 2001
From: Gokulakrishna Sudharsan <gokulakrishnaks@gmail.com>
Date: Sat, 2 Jun 2018 19:14:46 +0530
Subject: [PATCH] Show injected count in menu entry title in Firefox Android

---
 core/state-manager.js        |  8 ++++++++
 modules/internal/wrappers.js | 10 ++++++++++
 2 files changed, 18 insertions(+)

diff --git a/core/state-manager.js b/core/state-manager.js
index ba7d472..8f4639b 100644
--- a/core/state-manager.js
+++ b/core/state-manager.js
@@ -44,6 +44,14 @@ stateManager.registerInjection = function (tabIdentifier, injection) {
         }
     }
 
+    if (injectionCount > 0) {
+        let title = 'Decentraleyes (' + injectionCount.toString() + ')'; 
+        wrappers.setTitle({
+            'title': title, 
+            'tabId': tabIdentifier
+        });
+    }
+
     if (isNaN(interceptor.amountInjected)) {
 
         chrome.storage.local.get(Setting.AMOUNT_INJECTED, function (items) {
diff --git a/modules/internal/wrappers.js b/modules/internal/wrappers.js
index faf1033..5ea28dd 100644
--- a/modules/internal/wrappers.js
+++ b/modules/internal/wrappers.js
@@ -36,3 +36,13 @@ wrappers.setBadgeText = function (details) {
         chrome.browserAction.setBadgeText(details);
     }
 };
+
+// In firefox android, browser action shows as a menu entry instead of icon.
+// Use the below 'setTitle' to show injected count in menu entry.
+
+wrappers.setTitle = function (details){ 
+     
+    if (chrome.browserAction.setTitle !== undefined) {
+        chrome.browserAction.setTitle(details); 
+    }
+}; 
-- 
GitLab