mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-17 06:35:37 +07:00
Add interface features
+ statistics for totally blocked elements + statistics for percentage of total traffic
This commit is contained in:
41
popup.js
41
popup.js
@@ -1,6 +1,7 @@
|
||||
function init()
|
||||
{
|
||||
setStatus();
|
||||
changeStatistics();
|
||||
}
|
||||
|
||||
function setStatus()
|
||||
@@ -40,9 +41,49 @@ function changeStatus(){
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the globalCounter value from the browser storage
|
||||
* @param {(data){} Return value form browser.storage.local.get
|
||||
*/
|
||||
function changeStatistics(){
|
||||
var element = $("#statistics_value");
|
||||
var globalPercentage = $("#statistics_value_global_percentage");
|
||||
var globalCounter;
|
||||
var globalURLCounter;
|
||||
|
||||
browser.storage.local.get('globalCounter', function(data){
|
||||
if(data.globalCounter){
|
||||
globalCounter = data.globalCounter;
|
||||
}
|
||||
else {
|
||||
globalCounter = 0;
|
||||
}
|
||||
|
||||
element.text(globalCounter.toLocaleString());
|
||||
});
|
||||
|
||||
browser.storage.local.get('globalURLCounter', function(data){
|
||||
if(data.globalURLCounter){
|
||||
globalURLCounter = data.globalURLCounter;
|
||||
}
|
||||
else {
|
||||
globalURLCounter = 0;
|
||||
}
|
||||
|
||||
globalPercentage.text((globalCounter/globalURLCounter).toFixed(3)+"%");
|
||||
});
|
||||
};
|
||||
|
||||
function resetGlobalCounter(){
|
||||
browser.storage.local.set({"globalCounter": 0});
|
||||
browser.storage.local.set({"globalURLCounter": 0});
|
||||
};
|
||||
|
||||
$(document).ready(function(){
|
||||
init();
|
||||
//Hier neue ID des Mülleimers
|
||||
$("#globalStatus").on("click", changeStatus);
|
||||
$('.reset_counter_btn').on("click", resetGlobalCounter);
|
||||
|
||||
browser.storage.onChanged.addListener(changeStatistics);
|
||||
});
|
||||
Reference in New Issue
Block a user