-
@@ -25,7 +25,13 @@
+
+
diff --git a/clearurls.js b/clearurls.js index 485a8af..503689d 100644 --- a/clearurls.js +++ b/clearurls.js @@ -8,6 +8,7 @@ var providers = []; var prvKeys = []; var globalStatus; var badges = []; +var badgedStatus; var tabid = 0; var globalCounter; var globalURLCounter; @@ -205,7 +206,14 @@ function removeFieldsFormURL(provider, request) } browser.storage.local.set({"globalCounter": ++globalCounter}); - browser.browserAction.setBadgeText({text: (++badges[tabid]).toString(), tabId: tabid}); + if(badgedStatus) { + browser.browserAction.setBadgeText({text: (++badges[tabid]).toString(), tabId: tabid}); + } + else + { + browser.browserAction.setBadgeText({text: "", tabId: tabid}); + } + changes = true; } } @@ -217,7 +225,13 @@ function removeFieldsFormURL(provider, request) } browser.storage.local.set({"globalCounter": ++globalCounter}); - browser.browserAction.setBadgeText({text: (++badges[tabid]).toString(), tabId: tabid}); + if(badgedStatus) { + browser.browserAction.setBadgeText({text: (++badges[tabid]).toString(), tabId: tabid}); + } + else + { + browser.browserAction.setBadgeText({text: "", tabId: tabid}); + } cancel = true; } @@ -237,8 +251,8 @@ function removeFieldsFormURL(provider, request) */ function countFields(url) { - var matches = url.match(/[a-z\d]+=[a-z\d]+/gi); - var count = matches? matches.length : 0; + var matches = (url.match(/[^\/|\?|&]+=[^\/|\?|&]+/gi) || []); + var count = matches.length; return count; } @@ -332,12 +346,36 @@ function setGlobalCounter() { }); } +/** + * Get the badged status from the browser storage and put the value + * into a local variable. + * + */ +function setBadgedStatus() { + browser.storage.local.get('badgedStatus', function(data) { + if(data.badgedStatus) { + badgedStatus = data.badgedStatus; + browser.browserAction.setBadgeBackgroundColor({ + 'color': 'orange' + }); + } + else if(data.badgedStatus === null || typeof(data.badgedStatus) == "undefined"){ + badgedStatus = false; + } + else { + badgedStatus = false; + } + }); +} + +setBadgedStatus(); setGlobalCounter(); /** * Call by each change in the browser storage. */ browser.storage.onChanged.addListener(setGlobalCounter); +browser.storage.onChanged.addListener(setBadgedStatus); /** * Call by each tab is closed. diff --git a/manifest.json b/manifest.json index 56eef4f..e2f1bbb 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "ClearURLs", - "version": "1.1.1.3", + "version": "1.1.1.4", "author": "Kevin R., Arne S.", "description": "Remove tracking elements form URLs. ", "homepage_url": "https://github.com/KevinRoebert/ClearUrls", diff --git a/popup.html b/popup.html index 2f1e13b..28387b0 100644 --- a/popup.html +++ b/popup.html @@ -10,13 +10,13 @@