diff --git a/manifest.json b/manifest.json index e2c3c983..6fec598b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Resource Override", - "version": "1.0.0", + "version": "1.1.0", "description": "An extension to help you gain full control of any website by redirecting traffic, replacing, editing, or inserting new content.", "icons": { "16": "icons/icon-16x16.png", diff --git a/src/background/background.js b/src/background/background.js index 9e84e6d9..f90cd339 100644 --- a/src/background/background.js +++ b/src/background/background.js @@ -5,6 +5,7 @@ var ruleDomains = {}; var syncFunctions = []; + var badgeMap = new Map(); var logOnTab = function(tabId, message, important) { if (localStorage.showLogs === "true") { @@ -33,6 +34,8 @@ var updateTabCallback = function(tabId, changeinfo, tab) { urls[tabId] = tab.url; + badgeMap.set(tabId, 0); + updateBadge(tabId, ''); }; // Not all tabs will fire an update event. If the page is pre-rendered, @@ -48,6 +51,7 @@ closeListeners.forEach(function(fn) { fn(urls[tabId]); }); + badgeMap.delete(tabId); delete urls[tabId]; }; @@ -227,6 +231,9 @@ var matchedObj = match(ruleObj.match, requestUrl); var newUrl = matchReplace(matchedObj, ruleObj.replace, requestUrl); if (matchedObj.matched) { + var badgeCount = badgeMap.get(tabId) || 0; + badgeMap.set(tabId, ++badgeCount); + updateBadge(tabId, '' + badgeCount); logOnTab(tabId, "URL Override Matched: " + requestUrl + " to: " + newUrl + " match url: " + ruleObj.match, true); if (requestUrl !== newUrl) { @@ -240,6 +247,10 @@ } else if (ruleObj.type === "fileOverride" && match(ruleObj.match, requestUrl).matched) { + var badgeCount = badgeMap.get(tabId) || 0; + badgeMap.set(tabId, ++badgeCount); + updateBadge(tabId, '' + badgeCount); + logOnTab(tabId, "File Override Matched: " + requestUrl + " match url: " + ruleObj.match, true); @@ -357,6 +368,13 @@ return headerObjToReturn; }; + var updateBadge = function(tabId, text) { + if (localStorage.showBadgeCount === "false") return; + var color = '#099'; + chrome.browserAction.setBadgeText(text && { text, tabId }); + chrome.browserAction.setBadgeBackgroundColor({ color, tabId }); + }; + // Called when the user clicks on the browser action icon. chrome.browserAction.onClicked.addListener(function(tab) { openOrFocusOptionsPage(); diff --git a/src/ui/devtoolstab.html b/src/ui/devtoolstab.html index 5ea970c1..220b3815 100644 --- a/src/ui/devtoolstab.html +++ b/src/ui/devtoolstab.html @@ -208,6 +208,10 @@