Version 1.16.0

#362
#440
#429
#428
#431
This commit is contained in:
Kevin Röbert 2020-03-20 01:50:22 +01:00
parent b1a5b5fcb0
commit 0298792aa1
18 changed files with 299 additions and 163 deletions

View File

@ -4,6 +4,30 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.16.0] - 2020-03-20
### Compatibility note
- Require Firefox >= 55
- Require Chrome >= 22
### Added
- Added ETag header filtering [#362](https://gitlab.com/KevinRoebert/ClearUrls/issues/362), [#440](https://gitlab.com/KevinRoebert/ClearUrls/issues/440). Hint: Cache must be cleared before first use, to delete the already existing ETags.
### Fixed
- Fixed spontaneous disappearance of the badged
- Fixed wrong counting of blocked elements corrected (too little was ;D)
### Changed
- Updated all translation
- Changed badged font color to #FFFFFF
- Changed watchdog behavior as follows [#428](https://gitlab.com/KevinRoebert/ClearUrls/issues/428), [#431](https://gitlab.com/KevinRoebert/ClearUrls/issues/431), [#429](https://gitlab.com/KevinRoebert/ClearUrls/issues/429):
- Increased watchdog interval to 60 seconds
- Executed watchdog only if ClearURLs is also active
- Watchdog restarts ClearURLs at most 3 times and only if ClearURLs has rules
- Changed behavior of downloading rules [#428](https://gitlab.com/KevinRoebert/ClearUrls/issues/428), [#431](https://gitlab.com/KevinRoebert/ClearUrls/issues/431), [#429](https://gitlab.com/KevinRoebert/ClearUrls/issues/429):
- If download of hash file fails and no local rules are available, then ClearURLs displays `hash_status_code_5` and deactivates itself
- If download of rules file fails and no local rules are available, then ClearURLs displays `hash_status_code_5` and deactivates itself
## [1.15.0] - 2020-02-16 ## [1.15.0] - 2020-02-16
### Compatibility note ### Compatibility note

View File

@ -306,8 +306,14 @@
"description": "Diese Zeichenkette wird als Titel für das Referral-Marketing verwendet." "description": "Diese Zeichenkette wird als Titel für das Referral-Marketing verwendet."
}, },
"watchdog": { "watchdog": {
"message": "[ClearURLs]: Der Watchdog hat ein Problem festgestellt. ClearURLs wird neugestartet.", "message": "[ClearURLs]: Der Watchdog hat ein Problem festgestellt und ist bereits das $TIMES$-te mal gescheitert.",
"description": "Diese Zeichenkette wird als Text für den Watchdog verwendet." "description": "Diese Zeichenkette wird als Text für den Watchdog verwendet.",
"placeholders": {
"times": {
"content": "$1",
"example": "3"
}
}
}, },
"domain_blocking_enabled": { "domain_blocking_enabled": {
"message": "Erlaube Domain-Blocking (Kann zu Problemen auf Seiten führen, die AdBlocker nicht erlauben)", "message": "Erlaube Domain-Blocking (Kann zu Problemen auf Seiten führen, die AdBlocker nicht erlauben)",
@ -328,5 +334,17 @@
"ping_blocking_enabled_title": { "ping_blocking_enabled_title": {
"message": "Blockiere Hyperlink Auditing Anfragen", "message": "Blockiere Hyperlink Auditing Anfragen",
"description": "Diese Zeichenkette wird als Titel für das Hyperlink Auditing-Blocking verwendet." "description": "Diese Zeichenkette wird als Titel für das Hyperlink Auditing-Blocking verwendet."
},
"eTag_filtering_log": {
"message": "ETag-Header wurde aus dieser Anfrage entfernt",
"description": "Diese Zeichenkette wird für das Filtern von ETag-Headern im ClearURL-Protokoll verwendet."
},
"eTag_filtering_enabled": {
"message": "Filtert die ETag-Header aus den Anfragen (Siehe auch <a href='https://en.wikipedia.org/wiki/HTTP_ETag#Tracking_using_ETags' target='_blank'>diesen Artikel</a>)",
"description": "Diese Zeichenkette wird als Beschreibung für das Filtern von ETag-Headern verwendet."
},
"eTag_filtering_enabled_title": {
"message": "Filtert ETag-Header. Info: Cache muss vor der ersten Benutzung geleert werden.",
"description": "Diese Zeichenkette wird als Titel für das Filtern von ETag-Headern verwendet."
} }
} }

View File

@ -306,8 +306,14 @@
"description": "This string is used as title for the referral marketing switch" "description": "This string is used as title for the referral marketing switch"
}, },
"watchdog": { "watchdog": {
"message": "[ClearURLs]: The watchdog has detected a problem. ClearURLs is restarting.", "message": "[ClearURLs]: The watchdog has detected a problem and has already failed $TIMES$ times.",
"description": "This string is used as text for the watchdog" "description": "This string is used as text for the watchdog",
"placeholders": {
"times": {
"content": "$1",
"example": "3"
}
}
}, },
"domain_blocking_enabled": { "domain_blocking_enabled": {
"message": "Allow domain blocking (Can lead to problems on pages that do not allow AdBlockers)", "message": "Allow domain blocking (Can lead to problems on pages that do not allow AdBlockers)",
@ -328,5 +334,17 @@
"ping_blocking_enabled_title": { "ping_blocking_enabled_title": {
"message": "Block hyperlink auditing", "message": "Block hyperlink auditing",
"description": "This string is used as title for the hyperlink auditing blocking switch" "description": "This string is used as title for the hyperlink auditing blocking switch"
},
"eTag_filtering_log": {
"message": "ETag header was removed from this request",
"description": "This string is used on ETag header filtering in the ClearURLs log."
},
"eTag_filtering_enabled": {
"message": "Filters ETag headers from requests (See also <a href='https://en.wikipedia.org/wiki/HTTP_ETag#Tracking_using_ETags' target='_blank'>this article</a>)",
"description": "This string is used as label for the ETag header filtering switch"
},
"eTag_filtering_enabled_title": {
"message": "Filters ETag headers. Hint: Cache must be cleared before first use.",
"description": "This string is used as title for the ETag header filtering switch"
} }
} }

View File

@ -301,10 +301,6 @@
"message": "Permitir márketing de referidos", "message": "Permitir márketing de referidos",
"description": "This string is used as title for the referral marketing switch" "description": "This string is used as title for the referral marketing switch"
}, },
"watchdog": {
"message": "[ClearURLs]: El watchdog detectado un problema. ClearURLs será reiniciado.",
"description": "This string is used as text for the watchdog"
},
"domain_blocking_enabled": { "domain_blocking_enabled": {
"message": "Permitir bloqueo de dominios (Puede provocar problemas con sitios que no permitan bloqueadores de anuncios)", "message": "Permitir bloqueo de dominios (Puede provocar problemas con sitios que no permitan bloqueadores de anuncios)",
"description": "This string is used as label for the domain blocking switch" "description": "This string is used as label for the domain blocking switch"

View File

@ -301,10 +301,6 @@
"message": "Permettre certaines actions commerciales", "message": "Permettre certaines actions commerciales",
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options." "description": "Sert à afficher la signification de la fonction sur la page qui affiche les options."
}, },
"watchdog": {
"message": "[ClearURLs]: Temps ou délais dexécution imparti dépassé. ClearURLs doit redémarrer.",
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options."
},
"domain_blocking_enabled": { "domain_blocking_enabled": {
"message": "Bloquer les atteintes à la vie privée. Cependant, des sites décèlent la technique de protection et dysfonctionnent délibérément ou affichent des avertissements", "message": "Bloquer les atteintes à la vie privée. Cependant, des sites décèlent la technique de protection et dysfonctionnent délibérément ou affichent des avertissements",
"description": "Sert à afficher la signification de la fonction sur la page qui affiche les options." "description": "Sert à afficher la signification de la fonction sur la page qui affiche les options."

View File

@ -301,10 +301,6 @@
"message": "Permette l'utilizzo del referral marketing (esempio: Amazon)", "message": "Permette l'utilizzo del referral marketing (esempio: Amazon)",
"description": "This string is used as title for the referral marketing switch" "description": "This string is used as title for the referral marketing switch"
}, },
"watchdog": {
"message": "[ClearURLs]: Il sistema di controllo ha identificato un problema. ClearURLs verrà riavviato.",
"description": "This string is used as text for the watchdog"
},
"domain_blocking_enabled": { "domain_blocking_enabled": {
"message": "Permetti il blocco dei domini (può portare a problemi su pagine che non consentono AdBlocker)", "message": "Permetti il blocco dei domini (può portare a problemi su pagine che non consentono AdBlocker)",
"description": "This string is used as label for the domain blocking switch" "description": "This string is used as label for the domain blocking switch"

View File

@ -301,10 +301,6 @@
"message": "Разрешить рефералы маркетинга", "message": "Разрешить рефералы маркетинга",
"description": "This string is used as title for the referral marketing switch" "description": "This string is used as title for the referral marketing switch"
}, },
"watchdog": {
"message": "[ClearURLs]: сторожевой таймер обнаружил проблему. ClearURLs будет перезапущен.",
"description": "This string is used as text for the watchdog"
},
"domain_blocking_enabled": { "domain_blocking_enabled": {
"message": "Разрешить блокировку домена (может вызвать проблемы на сайтах, которые запрещают AdBlocker)", "message": "Разрешить блокировку домена (может вызвать проблемы на сайтах, которые запрещают AdBlocker)",
"description": "This string is used as label for the domain blocking switch" "description": "This string is used as label for the domain blocking switch"

View File

@ -301,10 +301,6 @@
"message": "Tillåt referral marketing", "message": "Tillåt referral marketing",
"description": "This string is used as title for the referral marketing switch" "description": "This string is used as title for the referral marketing switch"
}, },
"watchdog": {
"message": "[ClearURLs]: Ett problem har upptäckts. ClearURLs startar om.",
"description": "This string is used as text for the watchdog"
},
"domain_blocking_enabled": { "domain_blocking_enabled": {
"message": "Tillåt domänblockering (Kan leda till problem på sidor som inte tillåter AdBlockers)", "message": "Tillåt domänblockering (Kan leda till problem på sidor som inte tillåter AdBlockers)",
"description": "This string is used as label for the domain blocking switch" "description": "This string is used as label for the domain blocking switch"

View File

@ -301,10 +301,6 @@
"message": "Tavsiye pazarlamasına izin verir", "message": "Tavsiye pazarlamasına izin verir",
"description": "Bu dize tavsiye pazarlama anahtarı için başlık olarak kullanılır" "description": "Bu dize tavsiye pazarlama anahtarı için başlık olarak kullanılır"
}, },
"watchdog": {
"message": "[ClearURL'ler]: Güvenlik Zamanlayıcısı bir sorun tespit etti. ClearURL'ler yeniden başlatıldı.",
"description": "Bu dize güvenlik zamanlayıcısı için metin olarak kullanılır."
},
"domain_blocking_enabled": { "domain_blocking_enabled": {
"message": "Alan adı engellemeye izin ver (Reklam Engelleyicilere izin vermeyen sayfalarda sorunlara neden olabilir)", "message": "Alan adı engellemeye izin ver (Reklam Engelleyicilere izin vermeyen sayfalarda sorunlara neden olabilir)",
"description": "Bu dize, alan adı engelleme anahtarı için etiket olarak kullanılır" "description": "Bu dize, alan adı engelleme anahtarı için etiket olarak kullanılır"

View File

@ -22,13 +22,10 @@
*/ */
var providers = []; var providers = [];
var prvKeys = []; var prvKeys = [];
var badges = [];
var tabid = 0;
var siteBlockedAlert = 'javascript:void(0)'; var siteBlockedAlert = 'javascript:void(0)';
var dataHash; var dataHash;
var localDataHash; var localDataHash;
var os; var os;
var currentURL;
/** /**
* Helper function which remove the tracking fields * Helper function which remove the tracking fields
@ -36,10 +33,11 @@ var currentURL;
* *
* @param {Provider} provider Provider-Object * @param {Provider} provider Provider-Object
* @param pureUrl URL as String * @param pureUrl URL as String
* @param {boolean} quiet if the action should be displayed in log and statistics * @param {boolean} quiet if the action should be displayed in log and statistics
* @param {requestDetails} request the request details
* @return {Array} Array with changes and url fields * @return {Array} Array with changes and url fields
*/ */
function removeFieldsFormURL(provider, pureUrl, quiet = false) { function removeFieldsFormURL(provider, pureUrl, quiet = false, request = null) {
let url = pureUrl; let url = pureUrl;
let domain = ""; let domain = "";
let fragments = ""; let fragments = "";
@ -70,7 +68,7 @@ function removeFieldsFormURL(provider, pureUrl, quiet = false) {
pushToLog(beforeReplace, url, rawRule); pushToLog(beforeReplace, url, rawRule);
} }
increaseBadged(quiet); increaseBadged(quiet, request);
changes = true; changes = true;
} }
}); });
@ -91,7 +89,11 @@ function removeFieldsFormURL(provider, pureUrl, quiet = false) {
url = decodeURL(re); url = decodeURL(re);
//Log the action //Log the action
if (!quiet) pushToLog(pureUrl, url, translate('log_redirect')); if (!quiet) {
pushToLog(pureUrl, url, translate('log_redirect'));
increaseGlobalURLCounter(1);
increaseBadged(false, request)
};
return { return {
"redirect": true, "redirect": true,
@ -131,7 +133,7 @@ function removeFieldsFormURL(provider, pureUrl, quiet = false) {
if (!quiet) pushToLog(tempBeforeURL, tempURL, rule); if (!quiet) pushToLog(tempBeforeURL, tempURL, rule);
} }
increaseBadged(quiet); increaseBadged(quiet, request);
changes = true; changes = true;
} }
}); });
@ -146,7 +148,8 @@ function removeFieldsFormURL(provider, pureUrl, quiet = false) {
if (provider.isCaneling() && storage.domainBlocking) { if (provider.isCaneling() && storage.domainBlocking) {
if (!quiet) pushToLog(pureUrl, pureUrl, translate('log_domain_blocked')); if (!quiet) pushToLog(pureUrl, pureUrl, translate('log_domain_blocked'));
increaseBadged(quiet); increaseGlobalURLCounter(1);
increaseBadged(quiet, request);
cancel = true; cancel = true;
} }
@ -228,13 +231,26 @@ function start() {
} }
/** /**
* Get the hash for the rule file on github. * Deactivates ClearURLs, if no rules can be downloaded and also no old rules in storage
*/
function deactivateOnFailure() {
if(storage.ClearURLsData.length === 0) {
storage.globalStatus = false;
storage.dataHash = "";
changeIcon();
storeHashStatus(5);
saveOnExit();
}
}
/**
* Get the hash for the rule file on GitLab.
* Check the hash with the hash form the local file. * Check the hash with the hash form the local file.
* If the hash has changed, then download the new rule file. * If the hash has changed, then download the new rule file.
* Else do nothing. * Else do nothing.
*/ */
function getHash() { function getHash() {
//Get the target hash from github //Get the target hash from GitLab
fetch(storage.hashURL) fetch(storage.hashURL)
.then(function (response) { .then(function (response) {
const responseTextHash = response.clone().text().then(function (responseTextHash) { const responseTextHash = response.clone().text().then(function (responseTextHash) {
@ -250,6 +266,7 @@ function start() {
} }
} else { } else {
dataHash = false; dataHash = false;
deactivateOnFailure();
} }
}); });
}); });
@ -279,6 +296,8 @@ function start() {
storage.ClearURLsData = JSON.parse(storage.ClearURLsData); storage.ClearURLsData = JSON.parse(storage.ClearURLsData);
toObject(storage.ClearURLsData); toObject(storage.ClearURLsData);
saveOnDisk(['ClearURLsData', 'dataHash', 'hashStatus']); saveOnDisk(['ClearURLsData', 'dataHash', 'hashStatus']);
} else {
deactivateOnFailure();
} }
}); });
} }
@ -559,7 +578,8 @@ function start() {
if (storage.pingBlocking && storage.pingRequestTypes.includes(request.type)) { if (storage.pingBlocking && storage.pingRequestTypes.includes(request.type)) {
pushToLog(request.url, request.url, translate('log_ping_blocked')); pushToLog(request.url, request.url, translate('log_ping_blocked'));
increaseBadged(); increaseBadged(false, request);
increaseGlobalURLCounter(1);
return {cancel: true}; return {cancel: true};
} }
@ -567,9 +587,8 @@ function start() {
* Call for every provider the removeFieldsFormURL method. * Call for every provider the removeFieldsFormURL method.
*/ */
for (let i = 0; i < providers.length; i++) { for (let i = 0; i < providers.length; i++) {
if (providers[i].matchURL(request.url)) { if (providers[i].matchURL(request.url)) {
result = removeFieldsFormURL(providers[i], request.url); result = removeFieldsFormURL(providers[i], request.url, false, request);
} }
/* /*
@ -629,39 +648,6 @@ function start() {
getHash(); getHash();
setBadgedStatus(); setBadgedStatus();
/**
* Call by each tab is updated.
* And if url has changed.
*/
function handleUpdated(tabId, changeInfo, tabInfo) {
if (changeInfo.url) {
delete badges[tabId];
}
currentURL = tabInfo.url;
}
/**
* Call by each tab is updated.
*/
browser.tabs.onUpdated.addListener(handleUpdated);
/**
* Call by each tab change to set the actual tab id
*/
function handleActivated(activeInfo) {
tabid = activeInfo.tabId;
browser.tabs.get(tabid).then(function (tab) {
if (!browser.runtime.lastError) { // https://gitlab.com/KevinRoebert/ClearUrls/issues/346
currentURL = tab.url;
}
}).catch(handleError);
}
/**
* Call by each tab change.
*/
browser.tabs.onActivated.addListener(handleActivated);
/** /**
* Check the request. * Check the request.
*/ */
@ -697,53 +683,3 @@ function start() {
["blocking"] ["blocking"]
); );
} }
/**
* Function to log all activities from ClearUrls.
* Only logging when activated.
* The log is only temporary saved in the cache and will
* permanently saved with the saveLogOnClose function.
*
* @param beforeProcessing the url before the clear process
* @param afterProcessing the url after the clear process
* @param rule the rule that triggered the process
*/
function pushToLog(beforeProcessing, afterProcessing, rule) {
const limit = storage.logLimit;
if (storage.loggingStatus && limit !== 0) {
if (limit > 0 && !isNaN(limit)) {
while (storage.log.log.length >= limit) {
storage.log.log.shift();
}
}
storage.log.log.push(
{
"before": beforeProcessing,
"after": afterProcessing,
"rule": rule,
"timestamp": Date.now()
}
);
deferSaveOnDisk('log');
}
}
/**
* Increases the badged by one.
*/
function increaseBadged(quiet = false) {
if (badges[tabid] == null) badges[tabid] = 0;
if (!quiet) increaseURLCounter();
checkOSAndroid().then((res) => {
if (!res) {
if (storage.badgedStatus && !quiet) {
browser.browserAction.setBadgeText({text: (++badges[tabid]).toString(), tabId: tabid}).catch(handleError);
} else {
browser.browserAction.setBadgeText({text: "", tabId: tabid}).catch(handleError);
}
}
});
}

77
core_js/badgedHandler.js Normal file
View File

@ -0,0 +1,77 @@
/*
* ClearURLs
* Copyright (c) 2017-2020 Kevin Röbert
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*jshint esversion: 6 */
/*
* This script is responsible for setting the badged.
*/
let badges = {};
/**
* Increases the badged by one.
*/
function increaseBadged(quiet = false, request) {
if (!quiet) increaseURLCounter();
if(request === null) return;
const tabId = request.tabId;
const url = request.url;
if(tabId === -1) return;
if (badges[tabId] == null) {
badges[tabId] = {
counter: 1,
lastURL: url
};
} else {
badges[tabId].counter += 1;
}
checkOSAndroid().then((res) => {
if (!res) {
if (storage.badgedStatus && !quiet) {
browser.browserAction.setBadgeText({text: (badges[tabId]).counter.toString(), tabId: tabId}).catch(handleError);
} else {
browser.browserAction.setBadgeText({text: "", tabId: tabId}).catch(handleError);
}
}
});
}
/**
* Call by each tab is updated.
* And if url has changed.
*/
function handleUpdated(tabId, changeInfo, tabInfo) {
if(!badges[tabId] || !changeInfo.url) return;
if (badges[tabId].lastURL !== changeInfo.url) {
badges[tabId] = {
counter: 0,
lastURL: tabInfo.url
};
}
}
/**
* Call by each tab is updated.
*/
browser.tabs.onUpdated.addListener(handleUpdated);

45
core_js/eTagFilter.js Normal file
View File

@ -0,0 +1,45 @@
/*
* ClearURLs
* Copyright (c) 2017-2020 Kevin Röbert
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*jshint esversion: 6 */
/**
* Filters eTag headers from web requests.
*/
function eTagFilter(requestDetails) {
if(!requestDetails.responseHeaders || !storage.eTagFiltering) return {};
const responseHeaders = requestDetails.responseHeaders;
const filteredHeaders = responseHeaders.filter(header => {
return header.name.toLowerCase() !== "etag";
});
if(filteredHeaders.length < responseHeaders.length) {
pushToLog(requestDetails.url, requestDetails.url, translate("eTag_filtering_log"));
increaseBadged(false, requestDetails);
increaseGlobalURLCounter(1);
return {responseHeaders: filteredHeaders};
}
}
browser.webRequest.onHeadersReceived.addListener(
eTagFilter,
{urls: ["<all_urls>"]},
["blocking", "responseHeaders"]
);

View File

@ -115,6 +115,7 @@ function getData()
.then(() => loadData("referralMarketing")) .then(() => loadData("referralMarketing"))
.then(() => loadData("domainBlocking")) .then(() => loadData("domainBlocking"))
.then(() => loadData("pingBlocking")) .then(() => loadData("pingBlocking"))
.then(() => loadData("eTagFiltering"))
.then(() => { .then(() => {
changeSwitchButton("localHostsSkipping", "localHostsSkipping"); changeSwitchButton("localHostsSkipping", "localHostsSkipping");
changeSwitchButton("historyListenerEnabled", "historyListenerEnabled"); changeSwitchButton("historyListenerEnabled", "historyListenerEnabled");
@ -122,6 +123,7 @@ function getData()
changeSwitchButton("referralMarketing", "referralMarketing"); changeSwitchButton("referralMarketing", "referralMarketing");
changeSwitchButton("domainBlocking", "domainBlocking"); changeSwitchButton("domainBlocking", "domainBlocking");
changeSwitchButton("pingBlocking", "pingBlocking"); changeSwitchButton("pingBlocking", "pingBlocking");
changeSwitchButton("eTagFiltering", "eTagFiltering");
}).catch(handleError); }).catch(handleError);
} }
@ -189,6 +191,8 @@ function setText()
injectText("domain_blocking_enabled", "domain_blocking_enabled"); injectText("domain_blocking_enabled", "domain_blocking_enabled");
$('#ping_blocking_enabled').html(translate('ping_blocking_enabled')) $('#ping_blocking_enabled').html(translate('ping_blocking_enabled'))
.prop('title', translate('ping_blocking_enabled_title')); .prop('title', translate('ping_blocking_enabled_title'));
$('#eTag_filtering_enabled').html(translate('eTag_filtering_enabled'))
.prop('title', translate('eTag_filtering_enabled_title'))
} }
/** /**

View File

@ -202,6 +202,8 @@ function initSettings() {
storage.logLimit = -1; storage.logLimit = -1;
storage.domainBlocking = true; storage.domainBlocking = true;
storage.pingBlocking = true; storage.pingBlocking = true;
storage.eTagFiltering = true;
storage.watchDogErrorCount = 0;
if (getBrowser() === "Firefox") { if (getBrowser() === "Firefox") {
storage.types = ["font", "image", "imageset", "main_frame", "media", "object", "object_subrequest", "other", "script", "stylesheet", "sub_frame", "websocket", "xbl", "xml_dtd", "xmlhttprequest", "xslt"]; storage.types = ["font", "image", "imageset", "main_frame", "media", "object", "object_subrequest", "other", "script", "stylesheet", "sub_frame", "websocket", "xbl", "xml_dtd", "xmlhttprequest", "xslt"];
@ -268,6 +270,10 @@ function storeHashStatus(status_code) {
case 3: case 3:
status_code = "hash_status_code_3"; status_code = "hash_status_code_3";
break; break;
case 5:
status_code = "hash_status_code_5";
break;
case 4:
default: default:
status_code = "hash_status_code_4"; status_code = "hash_status_code_4";
} }

View File

@ -47,10 +47,12 @@ function isEmpty(obj) {
/** /**
* Translate a string with the i18n API. * Translate a string with the i18n API.
* *
* @param {string} string Name of the attribute used for localization * @param {string} string Name of the attribute used for localization
* @param {string[]} placeholders Array of placeholders
*/ */
function translate(string) { function translate(string, ...placeholders)
return browser.i18n.getMessage(string); {
return browser.i18n.getMessage(string, placeholders);
} }
/** /**
@ -181,32 +183,6 @@ function loadOldDataFromStore() {
localDataHash = storage.dataHash; localDataHash = storage.dataHash;
} }
/**
* Save the hash status to the local storage (RAM).
* The status can have the following values:
* 1 "up to date"
* 2 "updated"
* 3 "update available"
* @param status_code the number for the status
*/
function storeHashStatus(status_code) {
switch (status_code) {
case 1:
status_code = "hash_status_code_1";
break;
case 2:
status_code = "hash_status_code_2";
break;
case 3:
status_code = "hash_status_code_3";
break;
default:
status_code = "hash_status_code_4";
}
storage.hashStatus = status_code;
}
/** /**
* Increase by {number} the GlobalURLCounter * Increase by {number} the GlobalURLCounter
* @param {int} number * @param {int} number
@ -257,6 +233,9 @@ function setBadgedStatus() {
browser.browserAction.setBadgeBackgroundColor({ browser.browserAction.setBadgeBackgroundColor({
'color': color 'color': color
}).catch(handleError); }).catch(handleError);
browser.browserAction.setBadgeTextColor({
color: "#FFFFFF"
}).catch(handleError);
} }
}); });
} }
@ -305,4 +284,42 @@ Object.prototype.getOrDefault = function (key, defaultValue) {
function handleError(error) { function handleError(error) {
console.log(translate('core_error') + ":" + error); console.log(translate('core_error') + ":" + error);
}
/**
* Function to log all activities from ClearUrls.
* Only logging when activated.
* The log is only temporary saved in the cache and will
* permanently saved with the saveLogOnClose function.
*
* @param beforeProcessing the url before the clear process
* @param afterProcessing the url after the clear process
* @param rule the rule that triggered the process
*/
function pushToLog(beforeProcessing, afterProcessing, rule) {
const limit = storage.logLimit;
if (storage.loggingStatus && limit !== 0) {
if (limit > 0 && !isNaN(limit)) {
while (storage.log.log.length >= limit) {
storage.log.log.shift();
}
}
storage.log.log.push(
{
"before": beforeProcessing,
"after": afterProcessing,
"rule": rule,
"timestamp": Date.now()
}
);
deferSaveOnDisk('log');
}
}
/**
* Checks if the storage is available.
*/
function isStorageAvailable() {
return storage.ClearURLsData.length !== 0;
} }

View File

@ -24,15 +24,21 @@
* *
* This watchdog restarts the whole Add-on, when the check fails. * This watchdog restarts the whole Add-on, when the check fails.
*/ */
const CHECK_INTERVAL = 15000; const CHECK_INTERVAL = 60000;
setInterval(function() { setInterval(function() {
const dirtyURL = "https://clearurls.roebert.eu?utm_source=addon"; if(isStorageAvailable() && storage.globalStatus) {
const cleanURL = "https://clearurls.roebert.eu"; const dirtyURL = "https://clearurls.roebert.eu?utm_source=addon";
const cleanURL = "https://clearurls.roebert.eu";
if(pureCleaning(dirtyURL, true) !== cleanURL) { if(pureCleaning(dirtyURL, true) !== cleanURL) {
console.log(translate('watchdog')); storage.watchDogErrorCount += 1;
saveOnExit(); console.log(translate('watchdog', storage.watchDogErrorCount));
reload(); saveOnExit();
if(storage.watchDogErrorCount < 3) reload();
} else if(storage.watchDogErrorCount > 0){
storage.watchDogErrorCount = 0;
saveOnExit();
}
} }
}, CHECK_INTERVAL); }, CHECK_INTERVAL);

View File

@ -161,6 +161,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
<span class="slider round"></span> <span class="slider round"></span>
</label> </label>
</p> </p>
<p>
<label id="eTag_filtering_enabled" style="font-weight: bold;"></label><br />
<label class="switch">
<input type="checkbox" id="eTagFiltering">
<span class="slider round"></span>
</label>
</p>
<br /> <br />
<p class="text-center"> <p class="text-center">
<button type="button" id="save_settings_btn" <button type="button" id="save_settings_btn"

View File

@ -1,7 +1,7 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "ClearURLs", "name": "ClearURLs",
"version": "1.15.0", "version": "1.16.0",
"author": "Kevin Röbert", "author": "Kevin Röbert",
"description": "__MSG_extension_description__", "description": "__MSG_extension_description__",
"homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls", "homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",
@ -63,12 +63,14 @@
"core_js/message_handler.js", "core_js/message_handler.js",
"external_js/ip-range-check.js", "external_js/ip-range-check.js",
"core_js/tools.js", "core_js/tools.js",
"core_js/badgedHandler.js",
"core_js/pureCleaning.js", "core_js/pureCleaning.js",
"core_js/context_menu.js", "core_js/context_menu.js",
"core_js/historyListener.js", "core_js/historyListener.js",
"clearurls.js", "clearurls.js",
"core_js/storage.js", "core_js/storage.js",
"core_js/watchdog.js" "core_js/watchdog.js",
"core_js/eTagFilter.js"
] ]
}, },
"content_scripts": [ "content_scripts": [