Removed jQuery from core scripts
This commit is contained in:
parent
0acd24d716
commit
ae30c0eb53
|
@ -92,10 +92,6 @@ We use some third-party scripts in our add-on. The authors and licenses are list
|
||||||
- [jQuery v3.4.1](https://github.com/jquery/jquery/tree/3.4.1) |
|
- [jQuery v3.4.1](https://github.com/jquery/jquery/tree/3.4.1) |
|
||||||
Copyright JS Foundation and other contributors |
|
Copyright JS Foundation and other contributors |
|
||||||
[MIT](https://jquery.org/license/)
|
[MIT](https://jquery.org/license/)
|
||||||
- [sha256.jquery.plugin](https://github.com/orsozed/sha256.jquery.plugin) |
|
|
||||||
Copyright 2003, Christoph Bichlmeier |
|
|
||||||
[MIT](https://raw.github.com/orsozed/JQuery-Plugins/master/license/MIT-LICENSE.txt) |
|
|
||||||
[GPLv2](https://raw.github.com/orsozed/JQuery-Plugins/master/license/GPL-LICENSE.txt)
|
|
||||||
- [DataTables v1.10.20](https://github.com/DataTables/DataTables/tree/master) | Copyright (c) 2008-2015 SpryMedia Limited | [MIT](https://datatables.net/license/)
|
- [DataTables v1.10.20](https://github.com/DataTables/DataTables/tree/master) | Copyright (c) 2008-2015 SpryMedia Limited | [MIT](https://datatables.net/license/)
|
||||||
- [Popper.js v1.16.0](https://github.com/popperjs/popper.js/tree/v1.16.0) | Copyright (c) 2016 Federico Zivolo and contributors |
|
- [Popper.js v1.16.0](https://github.com/popperjs/popper.js/tree/v1.16.0) | Copyright (c) 2016 Federico Zivolo and contributors |
|
||||||
[MIT](https://github.com/popperjs/popper.js/blob/master/LICENSE.md)
|
[MIT](https://github.com/popperjs/popper.js/blob/master/LICENSE.md)
|
||||||
|
|
|
@ -346,5 +346,29 @@
|
||||||
"eTag_filtering_enabled_title": {
|
"eTag_filtering_enabled_title": {
|
||||||
"message": "Filters ETag headers. Hint: Cache must be cleared before first use.",
|
"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"
|
"description": "This string is used as title for the ETag header filtering switch"
|
||||||
|
},
|
||||||
|
"popup_html_rules_status_head_title": {
|
||||||
|
"message": "",
|
||||||
|
"description": "not needed, only to prevent exceptions"
|
||||||
|
},
|
||||||
|
"popup_html_statistics_percentage_title": {
|
||||||
|
"message": "",
|
||||||
|
"description": "not needed, only to prevent exceptions"
|
||||||
|
},
|
||||||
|
"popup_html_statistics_blocked_title": {
|
||||||
|
"message": "",
|
||||||
|
"description": "not needed, only to prevent exceptions"
|
||||||
|
},
|
||||||
|
"popup_html_statistics_elements_title": {
|
||||||
|
"message": "",
|
||||||
|
"description": "not needed, only to prevent exceptions"
|
||||||
|
},
|
||||||
|
"popup_html_statistics_head_title": {
|
||||||
|
"message": "",
|
||||||
|
"description": "not needed, only to prevent exceptions"
|
||||||
|
},
|
||||||
|
"popup_html_configs_head_title": {
|
||||||
|
"message": "",
|
||||||
|
"description": "not needed, only to prevent exceptions"
|
||||||
}
|
}
|
||||||
}
|
}
|
87
clearurls.js
87
clearurls.js
|
@ -251,25 +251,32 @@ function start() {
|
||||||
*/
|
*/
|
||||||
function getHash() {
|
function getHash() {
|
||||||
//Get the target hash from GitLab
|
//Get the target hash from GitLab
|
||||||
fetch(storage.hashURL)
|
const response = fetch(storage.hashURL).then(async response => {
|
||||||
.then(function (response) {
|
return {
|
||||||
const responseTextHash = response.clone().text().then(function (responseTextHash) {
|
hash: (await response.text()).trim(),
|
||||||
if (response.ok && $.trim(responseTextHash)) {
|
status: response.status
|
||||||
dataHash = responseTextHash;
|
};
|
||||||
|
});
|
||||||
|
|
||||||
if ($.trim(dataHash) !== $.trim(localDataHash)) {
|
response.then(result => {
|
||||||
fetchFromURL();
|
if (result.status === 200 && result.hash) {
|
||||||
} else {
|
dataHash = result.hash;
|
||||||
toObject(storage.ClearURLsData);
|
|
||||||
storeHashStatus(1);
|
if (dataHash !== localDataHash.trim()) {
|
||||||
saveOnDisk(['hashStatus']);
|
fetchFromURL();
|
||||||
}
|
} else {
|
||||||
} else {
|
toObject(storage.ClearURLsData);
|
||||||
dataHash = false;
|
storeHashStatus(1);
|
||||||
deactivateOnFailure();
|
saveOnDisk(['hashStatus']);
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
});
|
throw "The status code was not okay or the given hash were empty.";
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
console.error("[ClearURLs]: Could not download the rules hash from the given URL due to the following error: ", error);
|
||||||
|
dataHash = false;
|
||||||
|
deactivateOnFailure();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -278,29 +285,33 @@ function start() {
|
||||||
* ##################################################################
|
* ##################################################################
|
||||||
*/
|
*/
|
||||||
function fetchFromURL() {
|
function fetchFromURL() {
|
||||||
fetch(storage.ruleURL)
|
const response = fetch(storage.ruleURL).then(async response => {
|
||||||
.then(checkResponse);
|
return {
|
||||||
|
data: (await response.clone().text()).trim(),
|
||||||
|
hash: await sha256((await response.text()).trim()),
|
||||||
|
status: response.status
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
||||||
function checkResponse(response) {
|
response.then(result => {
|
||||||
const responseText = response.clone().text().then(function (responseText) {
|
if (result.status === 200 && result.data) {
|
||||||
if (response.ok && $.trim(responseText)) {
|
if (result.hash === dataHash.trim()) {
|
||||||
const downloadedFileHash = $.sha256(responseText);
|
storage.ClearURLsData = result.data;
|
||||||
|
storage.dataHash = result.hash;
|
||||||
if ($.trim(downloadedFileHash) === $.trim(dataHash)) {
|
storeHashStatus(2);
|
||||||
storage.ClearURLsData = responseText;
|
|
||||||
storage.dataHash = downloadedFileHash;
|
|
||||||
storeHashStatus(2);
|
|
||||||
} else {
|
|
||||||
storeHashStatus(3);
|
|
||||||
}
|
|
||||||
storage.ClearURLsData = JSON.parse(storage.ClearURLsData);
|
|
||||||
toObject(storage.ClearURLsData);
|
|
||||||
saveOnDisk(['ClearURLsData', 'dataHash', 'hashStatus']);
|
|
||||||
} else {
|
} else {
|
||||||
deactivateOnFailure();
|
storeHashStatus(3);
|
||||||
}
|
}
|
||||||
});
|
storage.ClearURLsData = JSON.parse(storage.ClearURLsData);
|
||||||
}
|
toObject(storage.ClearURLsData);
|
||||||
|
saveOnDisk(['ClearURLsData', 'dataHash', 'hashStatus']);
|
||||||
|
} else {
|
||||||
|
throw "The status code was not okay or the given rules were empty."
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
console.error("[ClearURLs]: Could not download the rules from the given URL due to the following error: ", error);
|
||||||
|
deactivateOnFailure();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// ##################################################################
|
// ##################################################################
|
||||||
|
|
|
@ -24,18 +24,18 @@ var length = 0;
|
||||||
/**
|
/**
|
||||||
* Load only when document is ready
|
* Load only when document is ready
|
||||||
*/
|
*/
|
||||||
$(document).ready(function(){
|
(function() {
|
||||||
setText();
|
setText();
|
||||||
$('#cleaning_tool_btn').on("click", cleanURLs);
|
document.getElementById('cleaning_tool_btn').onclick = cleanURLs;
|
||||||
});
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function cleans all URLs line by line in the textarea.
|
* This function cleans all URLs line by line in the textarea.
|
||||||
*/
|
*/
|
||||||
function cleanURLs() {
|
function cleanURLs() {
|
||||||
const cleanTArea = $('#cleanURLs');
|
const cleanTArea = document.getElementById('cleanURLs');
|
||||||
const dirtyTArea = $('#dirtyURLs');
|
const dirtyTArea = document.getElementById('dirtyURLs');
|
||||||
const urls = dirtyTArea.val().split('\n');
|
const urls = dirtyTArea.value.split('\n');
|
||||||
cleanedURLs = [];
|
cleanedURLs = [];
|
||||||
length = urls.length;
|
length = urls.length;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ function cleanURLs() {
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
cleanedURLs.push(data.response);
|
cleanedURLs.push(data.response);
|
||||||
if(i >= length-1) {
|
if(i >= length-1) {
|
||||||
cleanTArea.val(cleanedURLs.join('\n'));
|
cleanTArea.value= cleanedURLs.join('\n');
|
||||||
}
|
}
|
||||||
}, handleError);
|
}, handleError);
|
||||||
}
|
}
|
||||||
|
@ -68,11 +68,11 @@ function translate(string)
|
||||||
function setText()
|
function setText()
|
||||||
{
|
{
|
||||||
document.title = translate('cleaning_tool_page_title');
|
document.title = translate('cleaning_tool_page_title');
|
||||||
$('#page_title').text(translate('cleaning_tool_page_title'));
|
document.getElementById('page_title').textContent = translate('cleaning_tool_page_title');
|
||||||
$('#cleaning_tool_description').text(translate('cleaning_tool_description'));
|
document.getElementById('cleaning_tool_description').textContent = translate('cleaning_tool_description');
|
||||||
$('#cleaning_tool_btn').text(translate('cleaning_tool_btn'));
|
document.getElementById('cleaning_tool_btn').textContent = translate('cleaning_tool_btn');
|
||||||
$('#cleaning_tool_dirty_urls_label').text(translate('cleaning_tool_dirty_urls_label'));
|
document.getElementById('cleaning_tool_dirty_urls_label').textContent = translate('cleaning_tool_dirty_urls_label');
|
||||||
$('#cleaning_tool_clean_urls_label').text(translate('cleaning_tool_clean_urls_label'));
|
document.getElementById('cleaning_tool_clean_urls_label').textContent = translate('cleaning_tool_clean_urls_label');
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleError(error) {
|
function handleError(error) {
|
||||||
|
|
|
@ -17,11 +17,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*jshint esversion: 6 */
|
/*jshint esversion: 6 */
|
||||||
var element = $("#statistics_value");
|
var element = document.getElementById('statistics_value');
|
||||||
var elGlobalPercentage = $("#statistics_value_global_percentage");
|
var elGlobalPercentage = document.getElementById('statistics_value_global_percentage');
|
||||||
var elProgressbar_blocked = $('#progress_blocked');
|
var elProgressbar_blocked = document.getElementById('progress_blocked');
|
||||||
var elProgressbar_non_blocked = $('#progress_non_blocked');
|
var elProgressbar_non_blocked = document.getElementById('progress_non_blocked');
|
||||||
var elTotal = $('#statistics_total_elements');
|
var elTotal = document.getElementById('statistics_total_elements');
|
||||||
var globalPercentage = 0;
|
var globalPercentage = 0;
|
||||||
var globalCounter;
|
var globalCounter;
|
||||||
var globalurlcounter;
|
var globalurlcounter;
|
||||||
|
@ -55,11 +55,11 @@ function changeStatistics()
|
||||||
|
|
||||||
if(isNaN(Number(globalPercentage))) globalPercentage = 0;
|
if(isNaN(Number(globalPercentage))) globalPercentage = 0;
|
||||||
|
|
||||||
element.text(globalCounter.toLocaleString());
|
element.textContent = globalCounter.toLocaleString();
|
||||||
elGlobalPercentage.text(globalPercentage+"%");
|
elGlobalPercentage.textContent = globalPercentage+"%";
|
||||||
elProgressbar_blocked.css('width', globalPercentage+'%');
|
elProgressbar_blocked.style.width = globalPercentage+'%';
|
||||||
elProgressbar_non_blocked.css('width', (100-globalPercentage)+'%');
|
elProgressbar_non_blocked.style.width = (100-globalPercentage)+'%';
|
||||||
elTotal.text(globalurlcounter.toLocaleString());
|
elTotal.textContent = globalurlcounter.toLocaleString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -67,14 +67,14 @@ function changeStatistics()
|
||||||
*/
|
*/
|
||||||
function setHashStatus()
|
function setHashStatus()
|
||||||
{
|
{
|
||||||
let element = $('#hashStatus');
|
let element = document.getElementById('hashStatus');
|
||||||
|
|
||||||
if(hashStatus)
|
if(hashStatus)
|
||||||
{
|
{
|
||||||
element.text(translate(hashStatus));
|
element.textContent = translate(hashStatus);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
element.text(translate('hash_status_code_5'));
|
element.textContent = translate('hash_status_code_5');
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -86,14 +86,14 @@ function setHashStatus()
|
||||||
*/
|
*/
|
||||||
function changeSwitchButton(id, storageID)
|
function changeSwitchButton(id, storageID)
|
||||||
{
|
{
|
||||||
let element = $('#'+id);
|
let element = document.getElementById(id);
|
||||||
|
|
||||||
changeVisibility(id, storageID);
|
changeVisibility(id, storageID);
|
||||||
|
|
||||||
element.on('change', function(){
|
element.onchange = function(){
|
||||||
browser.runtime.sendMessage({
|
browser.runtime.sendMessage({
|
||||||
function: "setData",
|
function: "setData",
|
||||||
params: [storageID, element.is(':checked')]
|
params: [storageID, element.checked]
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
if(storageID === "globalStatus"){
|
if(storageID === "globalStatus"){
|
||||||
browser.runtime.sendMessage({
|
browser.runtime.sendMessage({
|
||||||
|
@ -108,7 +108,7 @@ function changeSwitchButton(id, storageID)
|
||||||
params: []
|
params: []
|
||||||
}).catch(handleError);
|
}).catch(handleError);
|
||||||
}).catch(handleError);
|
}).catch(handleError);
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,10 +121,10 @@ function changeVisibility(id, storageID)
|
||||||
switch(storageID)
|
switch(storageID)
|
||||||
{
|
{
|
||||||
case "loggingStatus":
|
case "loggingStatus":
|
||||||
element = $('#log_section');
|
element = document.getElementById('log_section');
|
||||||
break;
|
break;
|
||||||
case "statisticsStatus":
|
case "statisticsStatus":
|
||||||
element = $('#statistic_section');
|
element = document.getElementById('statistic_section');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
element = "undefine";
|
element = "undefine";
|
||||||
|
@ -132,14 +132,14 @@ function changeVisibility(id, storageID)
|
||||||
|
|
||||||
if(element !== "undefine")
|
if(element !== "undefine")
|
||||||
{
|
{
|
||||||
if($('#'+id).is(':checked'))
|
if(document.getElementById(id).checked)
|
||||||
{
|
{
|
||||||
element.css('display', '');
|
element.style.display = '';
|
||||||
element.css('display', '');
|
element.style.display = '';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
element.css('display', 'none');
|
element.style.display = 'none';
|
||||||
element.css('display', 'none');
|
element.style.display = 'none';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,8 +151,8 @@ function changeVisibility(id, storageID)
|
||||||
*/
|
*/
|
||||||
function setSwitchButton(id, varname)
|
function setSwitchButton(id, varname)
|
||||||
{
|
{
|
||||||
let element = $('#'+id);
|
const element = document.getElementById(id);
|
||||||
element.prop('checked', this[varname]);
|
element.checked = this[varname];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -180,7 +180,7 @@ function resetGlobalCounter(){
|
||||||
changeStatistics();
|
changeStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function(){
|
(function() {
|
||||||
loadData("globalCounter")
|
loadData("globalCounter")
|
||||||
.then(() => loadData("globalurlcounter"))
|
.then(() => loadData("globalurlcounter"))
|
||||||
.then(() => loadData("globalStatus"))
|
.then(() => loadData("globalStatus"))
|
||||||
|
@ -191,17 +191,17 @@ $(document).ready(function(){
|
||||||
.then(() => loadData("getCurrentURL", "currentURL"))
|
.then(() => loadData("getCurrentURL", "currentURL"))
|
||||||
.then(() => {
|
.then(() => {
|
||||||
init();
|
init();
|
||||||
$('#reset_counter_btn').on("click", resetGlobalCounter);
|
document.getElementById('reset_counter_btn').onclick = resetGlobalCounter;
|
||||||
changeSwitchButton("globalStatus", "globalStatus");
|
changeSwitchButton("globalStatus", "globalStatus");
|
||||||
changeSwitchButton("tabcounter", "badgedStatus");
|
changeSwitchButton("tabcounter", "badgedStatus");
|
||||||
changeSwitchButton("logging", "loggingStatus");
|
changeSwitchButton("logging", "loggingStatus");
|
||||||
changeSwitchButton("statistics", "statisticsStatus");
|
changeSwitchButton("statistics", "statisticsStatus");
|
||||||
$('#loggingPage').attr('href', browser.extension.getURL('./html/log.html'));
|
document.getElementById('loggingPage').href = browser.extension.getURL('./html/log.html');
|
||||||
$('#settings').attr('href', browser.extension.getURL('./html/settings.html'));
|
document.getElementById('settings').href = browser.extension.getURL('./html/settings.html');
|
||||||
$('#cleaning_tools').attr('href', browser.extension.getURL('./html/cleaningTool.html'));
|
document.getElementById('cleaning_tools').href = browser.extension.getURL('./html/cleaningTool.html');
|
||||||
setText();
|
setText();
|
||||||
});
|
});
|
||||||
});
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the text for the UI.
|
* Set the text for the UI.
|
||||||
|
@ -220,7 +220,7 @@ function setText()
|
||||||
injectText('configs_switch_filter','popup_html_configs_switch_filter');
|
injectText('configs_switch_filter','popup_html_configs_switch_filter');
|
||||||
injectText('configs_head','popup_html_configs_head');
|
injectText('configs_head','popup_html_configs_head');
|
||||||
injectText('configs_switch_statistics','configs_switch_statistics');
|
injectText('configs_switch_statistics','configs_switch_statistics');
|
||||||
$('#donate').prop('title', translate('donate_button'));
|
document.getElementById('donate').title = translate('donate_button');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -232,8 +232,8 @@ function setText()
|
||||||
*/
|
*/
|
||||||
function injectText(id, attribute, tooltip = "")
|
function injectText(id, attribute, tooltip = "")
|
||||||
{
|
{
|
||||||
let object = $('#'+id);
|
const object = document.getElementById(id);
|
||||||
object.text(translate(attribute));
|
object.textContent = translate(attribute);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This function will throw an error if no translation
|
This function will throw an error if no translation
|
||||||
|
@ -243,7 +243,7 @@ function injectText(id, attribute, tooltip = "")
|
||||||
|
|
||||||
if(tooltip !== "")
|
if(tooltip !== "")
|
||||||
{
|
{
|
||||||
object.prop('title', tooltip);
|
object.setAttribute('title', tooltip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,18 +27,18 @@
|
||||||
function setText()
|
function setText()
|
||||||
{
|
{
|
||||||
document.title = translate('blocked_html_title');
|
document.title = translate('blocked_html_title');
|
||||||
$('#title').html(translate('blocked_html_title'));
|
document.getElementById('title').innerHTML = translate('blocked_html_title');
|
||||||
$('#body').html(translate('blocked_html_body'));
|
document.getElementById('body').innerHTML = translate('blocked_html_body');
|
||||||
$('#page').text(translate('blocked_html_button'));
|
document.getElementById('page').textContent = translate('blocked_html_button');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function(){
|
(function() {
|
||||||
setText();
|
setText();
|
||||||
|
|
||||||
let source = new URLSearchParams(window.location.search).get("source");
|
const source = new URLSearchParams(window.location.search).get("source");
|
||||||
$('#page').attr('href', decodeURIComponent(source));
|
document.getElementById('page').href = decodeURIComponent(source);
|
||||||
});
|
})();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate a string with the i18n API.
|
* Translate a string with the i18n API.
|
||||||
|
|
|
@ -206,7 +206,7 @@ function initSettings() {
|
||||||
storage.watchDogErrorCount = 0;
|
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", "xml_dtd", "xmlhttprequest", "xslt"];
|
||||||
storage.pingRequestTypes = ["ping", "beacon"];
|
storage.pingRequestTypes = ["ping", "beacon"];
|
||||||
} else if (getBrowser() === "Chrome") {
|
} else if (getBrowser() === "Chrome") {
|
||||||
storage.types = ["main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest", "ping", "csp_report", "media", "websocket", "other"];
|
storage.types = ["main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest", "ping", "csp_report", "media", "websocket", "other"];
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
* This script is responsible for some tools.
|
* This script is responsible for some tools.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// Needed by the sha256 method
|
||||||
|
const enc = new TextEncoder();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* To support Waterfox.
|
* To support Waterfox.
|
||||||
*/
|
*/
|
||||||
|
@ -287,7 +290,7 @@ Object.prototype.getOrDefault = function (key, defaultValue) {
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleError(error) {
|
function handleError(error) {
|
||||||
console.log("[ClearURLs ERROR]:" + error);
|
console.error("[ClearURLs ERROR]:" + error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -326,4 +329,21 @@ function pushToLog(beforeProcessing, afterProcessing, rule) {
|
||||||
*/
|
*/
|
||||||
function isStorageAvailable() {
|
function isStorageAvailable() {
|
||||||
return storage.ClearURLsData.length !== 0;
|
return storage.ClearURLsData.length !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method calculates the SHA-256 hash as HEX string of the given message.
|
||||||
|
* This method uses the native hashing implementations of the SubtleCrypto interface which is supported by all browsers
|
||||||
|
* that implement the Web Cryptography API specification and is based on:
|
||||||
|
* https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||||
|
*
|
||||||
|
* @param message message for which the hash should be calculated
|
||||||
|
* @returns {Promise<string>} SHA-256 of the given message
|
||||||
|
*/
|
||||||
|
async function sha256(message) {
|
||||||
|
const msgUint8 = enc.encode(message);
|
||||||
|
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8);
|
||||||
|
const hashArray = Array.from(new Uint8Array(hashBuffer));
|
||||||
|
|
||||||
|
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||||
}
|
}
|
|
@ -21,4 +21,4 @@
|
||||||
* @return version
|
* @return version
|
||||||
*/
|
*/
|
||||||
const version = browser.runtime.getManifest().version;
|
const version = browser.runtime.getManifest().version;
|
||||||
$('#version').text(version);
|
document.getElementById('version').textContent = version;
|
||||||
|
|
|
@ -1,247 +0,0 @@
|
||||||
/*
|
|
||||||
* A JavaScript implementation of the SHA256 hash function.
|
|
||||||
*
|
|
||||||
* FILE: sha256.jquery.debug.js
|
|
||||||
* VERSION: 1.0
|
|
||||||
*
|
|
||||||
* MODIFICATION BY: Jacob Bair <orso.zed@gmail.com>
|
|
||||||
* ORIGINAL AUTHOR: Christoph Bichlmeier <informatik@zombiearena.de>
|
|
||||||
*
|
|
||||||
* NOTE: This version is not tested thoroughly!
|
|
||||||
*
|
|
||||||
* Copyright (c) 2003, Christoph Bichlmeier
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
* 3. Neither the name of the copyright holder nor the names of contributors
|
|
||||||
* may be used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* ======================================================================
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS
|
|
||||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
||||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE
|
|
||||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
||||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
||||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
|
||||||
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
||||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
||||||
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
|
||||||
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
(function($) {
|
|
||||||
$.sha256 = function(data) {
|
|
||||||
var ihash, count, buffer;
|
|
||||||
var hex_digits = "0123456789abcdef";
|
|
||||||
|
|
||||||
/* Hash constant words K: */
|
|
||||||
var K256 = new Array(
|
|
||||||
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
|
|
||||||
0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
|
|
||||||
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
|
|
||||||
0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
|
|
||||||
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
|
|
||||||
0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
|
|
||||||
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
|
|
||||||
0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
|
|
||||||
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
|
|
||||||
0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
|
|
||||||
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
|
|
||||||
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
|
|
||||||
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
|
|
||||||
0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
|
|
||||||
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
|
|
||||||
0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
|
|
||||||
);
|
|
||||||
|
|
||||||
var rotateRight = function(n, x) {
|
|
||||||
return ((x >>> n) | (x << (32 - n)));
|
|
||||||
};
|
|
||||||
|
|
||||||
var choice = function(x, y, z) {
|
|
||||||
return ((x & y) ^ (~x & z));
|
|
||||||
};
|
|
||||||
|
|
||||||
var majority = function(x, y, z) {
|
|
||||||
return ((x & y) ^ (x & z) ^ (y & z));
|
|
||||||
};
|
|
||||||
|
|
||||||
var Sigma0 = function(x) {
|
|
||||||
return (rotateRight(2, x) ^ rotateRight(13, x) ^ rotateRight(22, x));
|
|
||||||
};
|
|
||||||
|
|
||||||
var Sigma1 = function(x) {
|
|
||||||
return (rotateRight(6, x) ^ rotateRight(11, x) ^ rotateRight(25, x));
|
|
||||||
};
|
|
||||||
|
|
||||||
var sigma0 = function(x) {
|
|
||||||
return (rotateRight(7, x) ^ rotateRight(18, x) ^ (x >>> 3));
|
|
||||||
};
|
|
||||||
|
|
||||||
var sigma1 = function(x) {
|
|
||||||
return (rotateRight(17, x) ^ rotateRight(19, x) ^ (x >>> 10));
|
|
||||||
};
|
|
||||||
|
|
||||||
var expand = function(W, j) {
|
|
||||||
return (W[j & 0x0f] += sigma1(W[(j + 14) & 0x0f]) + W[(j + 9) & 0x0f] + sigma0(W[(j + 1) & 0x0f]));
|
|
||||||
};
|
|
||||||
|
|
||||||
var safe_add = function (x, y) {
|
|
||||||
var lsw = (x & 0xffff) + (y & 0xffff);
|
|
||||||
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
|
|
||||||
return (msw << 16) | (lsw & 0xffff);
|
|
||||||
};
|
|
||||||
|
|
||||||
var init = function() {
|
|
||||||
ihash = new Array(8);
|
|
||||||
count = new Array(2);
|
|
||||||
buffer = new Array(64);
|
|
||||||
count[0] = count[1] = 0;
|
|
||||||
ihash[0] = 0x6a09e667;
|
|
||||||
ihash[1] = 0xbb67ae85;
|
|
||||||
ihash[2] = 0x3c6ef372;
|
|
||||||
ihash[3] = 0xa54ff53a;
|
|
||||||
ihash[4] = 0x510e527f;
|
|
||||||
ihash[5] = 0x9b05688c;
|
|
||||||
ihash[6] = 0x1f83d9ab;
|
|
||||||
ihash[7] = 0x5be0cd19;
|
|
||||||
};
|
|
||||||
|
|
||||||
var update = function(data, length) {
|
|
||||||
var index, curpos = 0;
|
|
||||||
|
|
||||||
/* Compute number of bytes mod 64 */
|
|
||||||
index = ((count[0] >> 3) & 0x3f);
|
|
||||||
var remainder = (length & 0x3f);
|
|
||||||
|
|
||||||
/* Update number of bits */
|
|
||||||
if ((count[0] += (length << 3)) < (length << 3)) {
|
|
||||||
count[1]++;
|
|
||||||
}
|
|
||||||
count[1] += (length >> 29);
|
|
||||||
|
|
||||||
/* Transform as many times as possible */
|
|
||||||
for (var i = 0; i + 63 < length; i += 64) {
|
|
||||||
for (var j = index; j < 64; j++) {
|
|
||||||
buffer[j] = data.charCodeAt(curpos++);
|
|
||||||
}
|
|
||||||
transform();
|
|
||||||
index = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Buffer remaining input */
|
|
||||||
for (var k = 0; k < remainder; k++) {
|
|
||||||
buffer[k] = data.charCodeAt(curpos++);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var transform = function() {
|
|
||||||
var a, b, c, d, e, f, g, h, T1, T2;
|
|
||||||
var W = new Array(16);
|
|
||||||
|
|
||||||
/* Initialize registers with the previous intermediate value */
|
|
||||||
a = ihash[0];
|
|
||||||
b = ihash[1];
|
|
||||||
c = ihash[2];
|
|
||||||
d = ihash[3];
|
|
||||||
e = ihash[4];
|
|
||||||
f = ihash[5];
|
|
||||||
g = ihash[6];
|
|
||||||
h = ihash[7];
|
|
||||||
|
|
||||||
/* make 32-bit words */
|
|
||||||
for (var i = 0; i < 16; i++) {
|
|
||||||
W[i] = ((buffer[(i << 2) + 3]) | (buffer[(i << 2) + 2] << 8) | (buffer[(i << 2) + 1] << 16) | (buffer[i << 2] << 24));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var j = 0; j < 64; j++) {
|
|
||||||
T1 = h + Sigma1(e) + choice(e, f, g) + K256[j];
|
|
||||||
if (j < 16) {
|
|
||||||
T1 += W[j];
|
|
||||||
} else {
|
|
||||||
T1 += expand(W, j);
|
|
||||||
}
|
|
||||||
T2 = Sigma0(a) + majority(a, b, c);
|
|
||||||
h = g;
|
|
||||||
g = f;
|
|
||||||
f = e;
|
|
||||||
e = safe_add(d, T1);
|
|
||||||
d = c;
|
|
||||||
c = b;
|
|
||||||
b = a;
|
|
||||||
a = safe_add(T1, T2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Compute the current intermediate hash value */
|
|
||||||
ihash[0] += a;
|
|
||||||
ihash[1] += b;
|
|
||||||
ihash[2] += c;
|
|
||||||
ihash[3] += d;
|
|
||||||
ihash[4] += e;
|
|
||||||
ihash[5] += f;
|
|
||||||
ihash[6] += g;
|
|
||||||
ihash[7] += h;
|
|
||||||
};
|
|
||||||
|
|
||||||
var final = function() {
|
|
||||||
var index = ((count[0] >> 3) & 0x3f);
|
|
||||||
buffer[index++] = 0x80;
|
|
||||||
|
|
||||||
if (index <= 56) {
|
|
||||||
for (var i = index; i < 56; i++) {
|
|
||||||
buffer[i] = 0;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (var i = index; i < 64; i++) {
|
|
||||||
buffer[i] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
transform();
|
|
||||||
|
|
||||||
for (var i = 0; i < 56; i++) {
|
|
||||||
buffer[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer[56] = (count[1] >>> 24) & 0xff;
|
|
||||||
buffer[57] = (count[1] >>> 16) & 0xff;
|
|
||||||
buffer[58] = (count[1] >>> 8) & 0xff;
|
|
||||||
buffer[59] = count[1] & 0xff;
|
|
||||||
buffer[60] = (count[0] >>> 24) & 0xff;
|
|
||||||
buffer[61] = (count[0] >>> 16) & 0xff;
|
|
||||||
buffer[62] = (count[0] >>> 8) & 0xff;
|
|
||||||
buffer[63] = count[0] & 0xff;
|
|
||||||
|
|
||||||
transform();
|
|
||||||
};
|
|
||||||
|
|
||||||
var encode = function() {
|
|
||||||
var output = "";
|
|
||||||
for (var i = 0; i < 8; i++) {
|
|
||||||
for (var j = 28; j >= 0; j -= 4) {
|
|
||||||
output += hex_digits.charAt((ihash[i] >>> j) & 0x0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output;
|
|
||||||
};
|
|
||||||
|
|
||||||
if ($.isPlainObject(data) || $.isArray(data)) {
|
|
||||||
data = JSON.stringify(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
init();
|
|
||||||
update(data, data.length);
|
|
||||||
final();
|
|
||||||
|
|
||||||
return encode();
|
|
||||||
};
|
|
||||||
})(jQuery);
|
|
|
@ -77,8 +77,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<!-- Optional JavaScript -->
|
<!-- Optional JavaScript -->
|
||||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||||
<script src="../browser-polyfill.js"></script>
|
<script src="../browser-polyfill.js"></script>
|
||||||
<script src="../external_js/jquery-3.4.1.min.js"></script>
|
|
||||||
<script src="../external_js/bootstrap.min.js"></script>
|
|
||||||
<script src="../core_js/cleaning_tool.js"></script>
|
<script src="../core_js/cleaning_tool.js"></script>
|
||||||
<script src="../core_js/write_version.js"></script>
|
<script src="../core_js/write_version.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -113,9 +113,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||||
<script src="../browser-polyfill.js"></script>
|
<script src="../browser-polyfill.js"></script>
|
||||||
<script src="../external_js/jquery-3.4.1.min.js"></script>
|
<script src="../external_js/jquery-3.4.1.min.js"></script>
|
||||||
<script src="../external_js/bootstrap.min.js"></script>
|
|
||||||
<script src="../external_js/datatables.min.js"></script>
|
<script src="../external_js/datatables.min.js"></script>
|
||||||
<script src="../external_js/fontawesome/all.min.js"></script>
|
|
||||||
<script src="../core_js/log.js"></script>
|
<script src="../core_js/log.js"></script>
|
||||||
<script src="../core_js/write_version.js"></script>
|
<script src="../core_js/write_version.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -158,8 +158,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<!-- Optional JavaScript -->
|
<!-- Optional JavaScript -->
|
||||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||||
<script type="application/javascript" src="../browser-polyfill.js"></script>
|
<script type="application/javascript" src="../browser-polyfill.js"></script>
|
||||||
<script src="../external_js/jquery-3.4.1.min.js"></script>
|
|
||||||
<script src="../external_js/bootstrap.min.js"></script>
|
|
||||||
<script src="../external_js/fontawesome/all.min.js"></script>
|
<script src="../external_js/fontawesome/all.min.js"></script>
|
||||||
<script src="../core_js/popup.js"></script>
|
<script src="../core_js/popup.js"></script>
|
||||||
<script src="../core_js/write_version.js"></script>
|
<script src="../core_js/write_version.js"></script>
|
||||||
|
|
|
@ -182,7 +182,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<script src="../external_js/popper.min.js"></script>
|
<script src="../external_js/popper.min.js"></script>
|
||||||
<script src="../external_js/bootstrap.min.js"></script>
|
<script src="../external_js/bootstrap.min.js"></script>
|
||||||
<script src="../external_js/bootstrap-colorpicker.min.js"></script>
|
<script src="../external_js/bootstrap-colorpicker.min.js"></script>
|
||||||
<script src="../external_js/fontawesome/all.min.js"></script>
|
|
||||||
<script src="../core_js/settings.js"></script>
|
<script src="../core_js/settings.js"></script>
|
||||||
<script src="../core_js/write_version.js"></script>
|
<script src="../core_js/write_version.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -69,8 +69,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<!-- Optional JavaScript -->
|
<!-- Optional JavaScript -->
|
||||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||||
<script src="../browser-polyfill.js"></script>
|
<script src="../browser-polyfill.js"></script>
|
||||||
<script src="../external_js/jquery-3.4.1.min.js"></script>
|
|
||||||
<script src="../external_js/bootstrap.min.js"></script>
|
|
||||||
<script src="../core_js/siteBlockedAlert.js"></script>
|
<script src="../core_js/siteBlockedAlert.js"></script>
|
||||||
<script src="../core_js/write_version.js"></script>
|
<script src="../core_js/write_version.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -52,8 +52,6 @@
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"browser-polyfill.js",
|
"browser-polyfill.js",
|
||||||
"external_js/jquery-3.4.1.min.js",
|
|
||||||
"external_js/sha256.jquery.js",
|
|
||||||
"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",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user