Add Tabcounter (de)activation switch
Thanks to https://addons.mozilla.org/de/firefox/user/HardKoreG/ for the idea
This commit is contained in:
parent
3a4d2a7460
commit
942e0950a4
46
clearurls.js
46
clearurls.js
|
@ -8,6 +8,7 @@ var providers = [];
|
||||||
var prvKeys = [];
|
var prvKeys = [];
|
||||||
var globalStatus;
|
var globalStatus;
|
||||||
var badges = [];
|
var badges = [];
|
||||||
|
var badgedStatus;
|
||||||
var tabid = 0;
|
var tabid = 0;
|
||||||
var globalCounter;
|
var globalCounter;
|
||||||
var globalURLCounter;
|
var globalURLCounter;
|
||||||
|
@ -205,7 +206,14 @@ function removeFieldsFormURL(provider, request)
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.set({"globalCounter": ++globalCounter});
|
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;
|
changes = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -217,7 +225,13 @@ function removeFieldsFormURL(provider, request)
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.storage.local.set({"globalCounter": ++globalCounter});
|
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;
|
cancel = true;
|
||||||
}
|
}
|
||||||
|
@ -237,8 +251,8 @@ function removeFieldsFormURL(provider, request)
|
||||||
*/
|
*/
|
||||||
function countFields(url)
|
function countFields(url)
|
||||||
{
|
{
|
||||||
var matches = url.match(/[a-z\d]+=[a-z\d]+/gi);
|
var matches = (url.match(/[^\/|\?|&]+=[^\/|\?|&]+/gi) || []);
|
||||||
var count = matches? matches.length : 0;
|
var count = matches.length;
|
||||||
|
|
||||||
return count;
|
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();
|
setGlobalCounter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call by each change in the browser storage.
|
* Call by each change in the browser storage.
|
||||||
*/
|
*/
|
||||||
browser.storage.onChanged.addListener(setGlobalCounter);
|
browser.storage.onChanged.addListener(setGlobalCounter);
|
||||||
|
browser.storage.onChanged.addListener(setBadgedStatus);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call by each tab is closed.
|
* Call by each tab is closed.
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "ClearURLs",
|
"name": "ClearURLs",
|
||||||
"version": "1.1.1.3",
|
"version": "1.1.1.4",
|
||||||
"author": "Kevin R., Arne S.",
|
"author": "Kevin R., Arne S.",
|
||||||
"description": "Remove tracking elements form URLs. ",
|
"description": "Remove tracking elements form URLs. ",
|
||||||
"homepage_url": "https://github.com/KevinRoebert/ClearUrls",
|
"homepage_url": "https://github.com/KevinRoebert/ClearUrls",
|
||||||
|
|
12
popup.html
12
popup.html
|
@ -10,13 +10,13 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<div class="header">ClearURLs 1.1.1.3</div>
|
<div class="header">ClearURLs 1.1.1.4</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
<div id="default">
|
<div id="default">
|
||||||
<div id="global">
|
<div id="global">
|
||||||
Enable globally:<br>
|
Enable globally:<br>
|
||||||
<button id="globalStatus" class="status statusEnabled"></button>
|
<button id="globalStatus" class="status statusEnabled"></button>
|
||||||
</div>
|
</div><br>
|
||||||
<hr>
|
<hr>
|
||||||
<div id="statistics">
|
<div id="statistics">
|
||||||
Totally blocked elements:<br>
|
Totally blocked elements:<br>
|
||||||
|
@ -25,7 +25,13 @@
|
||||||
<span id="statistics_value_global_percentage" class="statistics_value"></span><br>
|
<span id="statistics_value_global_percentage" class="statistics_value"></span><br>
|
||||||
<div class="center">
|
<div class="center">
|
||||||
<button class="reset_counter_btn">Reset counter</button>
|
<button class="reset_counter_btn">Reset counter</button>
|
||||||
</div>
|
</div><br>
|
||||||
|
<hr><br>
|
||||||
|
<label class="switch">
|
||||||
|
<input type="checkbox" id="tabcounter">
|
||||||
|
<span class="slider round"></span>
|
||||||
|
<label>Tabcounter</label>
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
26
popup.js
26
popup.js
|
@ -2,6 +2,7 @@ function init()
|
||||||
{
|
{
|
||||||
setStatus();
|
setStatus();
|
||||||
changeStatistics();
|
changeStatistics();
|
||||||
|
setTabcounter();
|
||||||
}
|
}
|
||||||
|
|
||||||
function setStatus()
|
function setStatus()
|
||||||
|
@ -74,6 +75,30 @@ function changeStatistics(){
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function changeTabcounter() {
|
||||||
|
var element = $('#tabcounter').is(':checked');
|
||||||
|
|
||||||
|
browser.storage.local.set({'badgedStatus': element});
|
||||||
|
};
|
||||||
|
|
||||||
|
function setTabcounter() {
|
||||||
|
var element = $('#tabcounter');
|
||||||
|
|
||||||
|
browser.storage.local.get('badgedStatus', function(data) {
|
||||||
|
if(data.badgedStatus)
|
||||||
|
{
|
||||||
|
element.prop('checked', true);
|
||||||
|
}
|
||||||
|
else if(data.badgedStatus === null || typeof(data.badgedStatus) == "undefined"){
|
||||||
|
element.prop('checked', true);
|
||||||
|
browser.storage.local.set({'badgedStatus': true});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
element.prop('checked', false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function resetGlobalCounter(){
|
function resetGlobalCounter(){
|
||||||
browser.storage.local.set({"globalCounter": 0});
|
browser.storage.local.set({"globalCounter": 0});
|
||||||
browser.storage.local.set({"globalURLCounter": 0});
|
browser.storage.local.set({"globalURLCounter": 0});
|
||||||
|
@ -84,6 +109,7 @@ $(document).ready(function(){
|
||||||
//Hier neue ID des Mülleimers
|
//Hier neue ID des Mülleimers
|
||||||
$("#globalStatus").on("click", changeStatus);
|
$("#globalStatus").on("click", changeStatus);
|
||||||
$('.reset_counter_btn').on("click", resetGlobalCounter);
|
$('.reset_counter_btn').on("click", resetGlobalCounter);
|
||||||
|
$('#tabcounter').on('change', changeTabcounter);
|
||||||
|
|
||||||
browser.storage.onChanged.addListener(changeStatistics);
|
browser.storage.onChanged.addListener(changeStatistics);
|
||||||
});
|
});
|
Loading…
Reference in New Issue
Block a user