Add interface features

+ statistics for totally blocked elements
+ statistics for percentage of total traffic
This commit is contained in:
Kevin Röbert
2017-08-23 02:24:16 +02:00
parent 89086d38dd
commit 050c97a615
5 changed files with 154 additions and 1 deletions

View File

@@ -9,6 +9,8 @@ var prvKeys = [];
var globalStatus;
var badges = [];
var tabid = 0;
var globalCounter;
var globalURLCounter;
/**
* Initialize the JSON provider object keys.
@@ -203,6 +205,7 @@ function removeFieldsFormURL(provider, request)
}
browser.browserAction.setBadgeText({text: (++badges[tabid]).toString(), tabId: tabid});
browser.storage.local.set({"globalCounter": ++globalCounter});
changes = true;
}
}
@@ -228,6 +231,7 @@ function removeFieldsFormURL(provider, request)
*/
function clearUrl(request)
{
browser.storage.local.set({"globalURLCounter": ++globalURLCounter});
browser.storage.local.get('globalStatus', clear);
function clear(data){
@@ -280,6 +284,36 @@ function handleRemoved(tabId, removeInfo) {
delete badges[tabId];
}
/**
* Get the globalCounter value from the browser storage
* @param {(data){} Return value form browser.storage.local.get
*/
function setGlobalCounter() {
browser.storage.local.get('globalCounter', function(data){
if(data.globalCounter){
globalCounter = data.globalCounter;
}
else {
globalCounter = 0;
}
});
browser.storage.local.get('globalURLCounter', function(data){
if(data.globalURLCounter){
globalURLCounter = data.globalURLCounter;
}
else {
globalURLCounter = 0;
}
});
}
setGlobalCounter();
/**
* Call by each change in the browser storage.
*/
browser.storage.onChanged.addListener(setGlobalCounter);
/**
* Call by each tab is closed.
*/