Chrome support
This commit is contained in:
parent
869cd63e64
commit
03e0580b20
|
@ -1,892 +0,0 @@
|
||||||
/*
|
|
||||||
* ##################################################################
|
|
||||||
* # Fetch Rules & Exception from URL #
|
|
||||||
* ##################################################################
|
|
||||||
*/
|
|
||||||
var providers = [];
|
|
||||||
var prvKeys = [];
|
|
||||||
var badges = [];
|
|
||||||
var tabid = 0;
|
|
||||||
var siteBlockedAlert = 'javascript:void(0)';
|
|
||||||
var dataHash;
|
|
||||||
var localDataHash;
|
|
||||||
var os;
|
|
||||||
var currentURL;
|
|
||||||
|
|
||||||
var storage = [];
|
|
||||||
|
|
||||||
getDataFromDisk();
|
|
||||||
|
|
||||||
function start(items)
|
|
||||||
{
|
|
||||||
initStorage(items);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save OS Version
|
|
||||||
*/
|
|
||||||
chrome.runtime.getPlatformInfo(function(info) {
|
|
||||||
|
|
||||||
os = info.os;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the JSON provider object keys.
|
|
||||||
*
|
|
||||||
* @param {JSON Object} obj
|
|
||||||
*/
|
|
||||||
function getKeys(obj){
|
|
||||||
for(var key in obj){
|
|
||||||
prvKeys.push(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the providers form the JSON object.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function createProviders()
|
|
||||||
{
|
|
||||||
data = storage.ClearURLsData;
|
|
||||||
|
|
||||||
for(var p = 0; p < prvKeys.length; p++)
|
|
||||||
{
|
|
||||||
//Create new provider
|
|
||||||
providers.push(new Provider(prvKeys[p],data.providers[prvKeys[p]].completeProvider));
|
|
||||||
|
|
||||||
//Add URL Pattern
|
|
||||||
providers[p].setURLPattern(data.providers[prvKeys[p]].urlPattern);
|
|
||||||
|
|
||||||
//Add rules to provider
|
|
||||||
for(var r = 0; r < data.providers[prvKeys[p]].rules.length; r++)
|
|
||||||
{
|
|
||||||
providers[p].addRule(data.providers[prvKeys[p]].rules[r]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add exceptions to provider
|
|
||||||
for(var e = 0; e < data.providers[prvKeys[p]].exceptions.length; e++)
|
|
||||||
{
|
|
||||||
providers[p].addException(data.providers[prvKeys[p]].exceptions[e]);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Add redirections to provider
|
|
||||||
for(var re = 0; re < data.providers[prvKeys[p]].redirections.length; re++)
|
|
||||||
{
|
|
||||||
providers[p].addRedirection(data.providers[prvKeys[p]].redirections[re]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert the external data to Objects and
|
|
||||||
* call the create provider function.
|
|
||||||
*
|
|
||||||
* @param {String} retrievedText - pure data form github
|
|
||||||
*/
|
|
||||||
function toObject(retrievedText) {
|
|
||||||
getKeys(storage.ClearURLsData.providers);
|
|
||||||
createProviders();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load local saved data, if the browser is offline or
|
|
||||||
* some other network trouble.
|
|
||||||
*/
|
|
||||||
function loadOldDataFromStore()
|
|
||||||
{
|
|
||||||
localDataHash = storage.dataHash;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save the hash status to the local storage.
|
|
||||||
* 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the hash for the rule file on github.
|
|
||||||
* Check the hash with the hash form the local file.
|
|
||||||
* If the hash has changed, then download the new rule file.
|
|
||||||
* Else do nothing.
|
|
||||||
*/
|
|
||||||
function getHash()
|
|
||||||
{
|
|
||||||
//Get the target hash from github
|
|
||||||
fetch(storage.hashURL)
|
|
||||||
.then(function(response){
|
|
||||||
var responseTextHash = response.clone().text().then(function(responseTextHash){
|
|
||||||
if(response.ok)
|
|
||||||
{
|
|
||||||
dataHash = responseTextHash;
|
|
||||||
|
|
||||||
if($.trim(dataHash) !== $.trim(localDataHash))
|
|
||||||
{
|
|
||||||
fetchFromURL();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
toObject(storage.ClearURLsData);
|
|
||||||
storeHashStatus(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dataHash = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch the Rules & Exception from github.
|
|
||||||
*/
|
|
||||||
function fetchFromURL()
|
|
||||||
{
|
|
||||||
fetch(storage.ruleURL)
|
|
||||||
.then(checkResponse);
|
|
||||||
|
|
||||||
function checkResponse(response)
|
|
||||||
{
|
|
||||||
var responseText = response.clone().text().then(function(responseText){
|
|
||||||
if(response.ok)
|
|
||||||
{
|
|
||||||
var downloadedFileHash = $.sha256(responseText);
|
|
||||||
|
|
||||||
if($.trim(downloadedFileHash) === $.trim(dataHash))
|
|
||||||
{
|
|
||||||
storage.ClearURLsData = responseText;
|
|
||||||
storage.dataHash = downloadedFileHash;
|
|
||||||
storeHashStatus(2);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
storeHashStatus(3);
|
|
||||||
}
|
|
||||||
storage.ClearURLsData = JSON.parse(storage.ClearURLsData);
|
|
||||||
toObject(storage.ClearURLsData);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ##################################################################
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ##################################################################
|
|
||||||
* # Supertyp Provider #
|
|
||||||
* ##################################################################
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Declare constructor
|
|
||||||
*
|
|
||||||
* @param {String} _name Provider name
|
|
||||||
* @param {boolean} completeProvider Set URL Pattern as rule
|
|
||||||
*/
|
|
||||||
function Provider(_name,_completeProvider = false){
|
|
||||||
var name = _name;
|
|
||||||
var urlPattern;
|
|
||||||
var rules = [];
|
|
||||||
var exceptions = [];
|
|
||||||
var canceling = _completeProvider;
|
|
||||||
var redirections = [];
|
|
||||||
|
|
||||||
if(_completeProvider){
|
|
||||||
rules.push(".*");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the provider name.
|
|
||||||
* @return {String}
|
|
||||||
*/
|
|
||||||
this.getName = function() {
|
|
||||||
return name;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add URL pattern.
|
|
||||||
*
|
|
||||||
* @require urlPatterns as RegExp
|
|
||||||
*/
|
|
||||||
this.setURLPattern = function(urlPatterns) {
|
|
||||||
urlPattern = new RegExp(urlPatterns, "i");
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return if the Provider Request is canceled
|
|
||||||
* @return {Boolean} isCanceled
|
|
||||||
*/
|
|
||||||
this.isCaneling = function() {
|
|
||||||
return canceling;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check the url is matching the ProviderURL.
|
|
||||||
*
|
|
||||||
* @return {boolean} ProviderURL as RegExp
|
|
||||||
*/
|
|
||||||
this.matchURL = function(url) {
|
|
||||||
return !(this.matchException(url)) && urlPattern.test(url);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a rule to the rule array.
|
|
||||||
*
|
|
||||||
* @param String rule RegExp as string
|
|
||||||
*/
|
|
||||||
this.addRule = function(rule) {
|
|
||||||
rules.push(rule);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return all rules as an array.
|
|
||||||
*
|
|
||||||
* @return Array RegExp strings
|
|
||||||
*/
|
|
||||||
this.getRules = function() {
|
|
||||||
return rules;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a exception to the exceptions array.
|
|
||||||
*
|
|
||||||
* @param String exception RegExp as string
|
|
||||||
*/
|
|
||||||
this.addException = function(exception) {
|
|
||||||
exceptions.push(exception);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Private helper method to check if the url
|
|
||||||
* an exception.
|
|
||||||
*
|
|
||||||
* @param {String} url RegExp as string
|
|
||||||
* @return {boolean} if matching? true: false
|
|
||||||
*/
|
|
||||||
this.matchException = function(url) {
|
|
||||||
var result = false;
|
|
||||||
|
|
||||||
//Add the site blocked alert to every exception
|
|
||||||
if(url == siteBlockedAlert) return true;
|
|
||||||
|
|
||||||
for (var i = 0; i < exceptions.length; i++) {
|
|
||||||
if(result) { break; }
|
|
||||||
|
|
||||||
exception_regex = new RegExp(exceptions[i], "i");
|
|
||||||
result = exception_regex.test(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a redirection to the redirections array.
|
|
||||||
*
|
|
||||||
* @param String redirection RegExp as string
|
|
||||||
*/
|
|
||||||
this.addRedirection = function(redirection) {
|
|
||||||
redirections.push(redirection);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return all redirection.
|
|
||||||
*
|
|
||||||
* @return url
|
|
||||||
*/
|
|
||||||
this.getRedirection = function(url) {
|
|
||||||
var re = null;
|
|
||||||
|
|
||||||
for(var i = 0; i < redirections.length; i++)
|
|
||||||
{
|
|
||||||
result = (url.match(new RegExp(redirections[i], "i")));
|
|
||||||
|
|
||||||
if (result && result.length > 0)
|
|
||||||
{
|
|
||||||
re = (new RegExp(redirections[i], "i")).exec(url)[1];
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return re;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// ##################################################################
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function which remove the tracking fields
|
|
||||||
* for each provider given as parameter.
|
|
||||||
*
|
|
||||||
* @param {Provider} provider Provider-Object
|
|
||||||
* @param {webRequest} request webRequest-Object
|
|
||||||
* @return {Array} Array with changes and url fields
|
|
||||||
*/
|
|
||||||
function removeFieldsFormURL(provider, request)
|
|
||||||
{
|
|
||||||
var url = request.url;
|
|
||||||
var domain = url.replace(new RegExp("\\?.*", "i"), "");
|
|
||||||
var fields = "";
|
|
||||||
var rules = provider.getRules();
|
|
||||||
var changes = false;
|
|
||||||
var cancel = false;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Expand the url by provider redirections. So no tracking on
|
|
||||||
* url redirections form sites to sites.
|
|
||||||
*/
|
|
||||||
var re = provider.getRedirection(url);
|
|
||||||
if(re !== null)
|
|
||||||
{
|
|
||||||
url = decodeURIComponent(re);
|
|
||||||
//Log the action
|
|
||||||
pushToLog(request.url, re, translate('log_redirect'));
|
|
||||||
|
|
||||||
return {
|
|
||||||
"redirect": true,
|
|
||||||
"url": url
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Only test for matches, if there are fields that can be cleaned.
|
|
||||||
*/
|
|
||||||
if(existsFields(url))
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* It must be non-greedy, because by default .* will match
|
|
||||||
* all ? chars. So the replace function delete everything
|
|
||||||
* before the last ?. With adding a ? on the quantifier *,
|
|
||||||
* we fixed this problem.
|
|
||||||
*/
|
|
||||||
fields = url.replace(new RegExp(".*?\\?", "i"), "");
|
|
||||||
|
|
||||||
for (var i = 0; i < rules.length; i++) {
|
|
||||||
var beforReplace = fields;
|
|
||||||
|
|
||||||
fields = fields.replace(new RegExp(rules[i], "i"), "");
|
|
||||||
|
|
||||||
if(beforReplace != fields)
|
|
||||||
{
|
|
||||||
//Log the action
|
|
||||||
pushToLog(domain+"?"+beforReplace, domain+"?"+fields, rules[i]);
|
|
||||||
|
|
||||||
if(badges[tabid] == null)
|
|
||||||
{
|
|
||||||
badges[tabid] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
increaseURLCounter();
|
|
||||||
|
|
||||||
if(!checkOSAndroid())
|
|
||||||
{
|
|
||||||
if(storage.badgedStatus) {
|
|
||||||
browser.browserAction.setBadgeText({text: (++badges[tabid]).toString(), tabId: tabid});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
browser.browserAction.setBadgeText({text: "", tabId: tabid});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
changes = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
url = domain+"?"+fields;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(domain != url)
|
|
||||||
{
|
|
||||||
url = domain;
|
|
||||||
changes = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(provider.isCaneling()){
|
|
||||||
pushToLog(request.url, request.url, translate('log_domain_blocked'));
|
|
||||||
if(badges[tabid] == null)
|
|
||||||
{
|
|
||||||
badges[tabid] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
increaseURLCounter();
|
|
||||||
|
|
||||||
if(!checkOSAndroid())
|
|
||||||
{
|
|
||||||
if(storage.badgedStatus) {
|
|
||||||
browser.browserAction.setBadgeText({text: (++badges[tabid]).toString(), tabId: tabid});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
browser.browserAction.setBadgeText({text: "", tabId: tabid});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cancel = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
|
||||||
"changes": changes,
|
|
||||||
"url": url,
|
|
||||||
"cancel": cancel
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the number of parameters query strings.
|
|
||||||
* @param {String} url URL as String
|
|
||||||
* @return {int} Number of Parameters
|
|
||||||
*/
|
|
||||||
function countFields(url)
|
|
||||||
{
|
|
||||||
var matches = (url.match(/[^\/|\?|&]+=[^\/|\?|&]+/gi) || []);
|
|
||||||
var count = matches.length;
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if fields exists.
|
|
||||||
* @param {String} url URL as String
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
function existsFields(url)
|
|
||||||
{
|
|
||||||
var matches = (url.match(/\?.+/i) || []);
|
|
||||||
var count = matches.length;
|
|
||||||
|
|
||||||
return (count > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Function which called from the webRequest to
|
|
||||||
* remove the tracking fields from the url.
|
|
||||||
*
|
|
||||||
* @param {webRequest} request webRequest-Object
|
|
||||||
* @return {Array} redirectUrl or none
|
|
||||||
*/
|
|
||||||
function clearUrl(request)
|
|
||||||
{
|
|
||||||
var URLbeforeReplaceCount = countFields(request.url);
|
|
||||||
|
|
||||||
//Add Fields form Request to global url counter
|
|
||||||
increaseGlobalURLCounter(URLbeforeReplaceCount);
|
|
||||||
|
|
||||||
if(storage.globalStatus){
|
|
||||||
|
|
||||||
var result = {
|
|
||||||
"changes": false,
|
|
||||||
"url": "",
|
|
||||||
"redirect": false,
|
|
||||||
"cancel": false
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Call for every provider the removeFieldsFormURL method.
|
|
||||||
*/
|
|
||||||
for (var i = 0; i < providers.length; i++) {
|
|
||||||
|
|
||||||
if(providers[i].matchURL(request.url))
|
|
||||||
{
|
|
||||||
result = removeFieldsFormURL(providers[i], request);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Expand urls and bypass tracking.
|
|
||||||
* Cancel the active request.
|
|
||||||
*/
|
|
||||||
if(result.redirect)
|
|
||||||
{
|
|
||||||
browser.tabs.update(request.tabId, {url: result.url});
|
|
||||||
return {cancel: true};
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Cancel the Request and redirect to the site blocked alert page,
|
|
||||||
* to inform the user about the full url blocking.
|
|
||||||
*/
|
|
||||||
if(result.cancel){
|
|
||||||
return {
|
|
||||||
redirectUrl: siteBlockedAlert
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Ensure that the function go not into
|
|
||||||
* a loop.
|
|
||||||
*/
|
|
||||||
if(result.changes){
|
|
||||||
return {
|
|
||||||
redirectUrl: result.url
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default case
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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)
|
|
||||||
{
|
|
||||||
if(storage.loggingStatus)
|
|
||||||
{
|
|
||||||
storage.log.log.push(
|
|
||||||
{
|
|
||||||
"before": beforeProcessing,
|
|
||||||
"after": afterProcessing,
|
|
||||||
"rule": rule,
|
|
||||||
"timestamp": Date.now()
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call loadOldDataFromStore, getHash, counter, status and log functions
|
|
||||||
*/
|
|
||||||
|
|
||||||
loadOldDataFromStore();
|
|
||||||
getHash();
|
|
||||||
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) {
|
|
||||||
currentURL = tab.url;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call by each tab change.
|
|
||||||
*/
|
|
||||||
browser.tabs.onActivated.addListener(handleActivated);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check the request.
|
|
||||||
*/
|
|
||||||
function promise(requestDetails)
|
|
||||||
{
|
|
||||||
if(isDataURL(requestDetails))
|
|
||||||
{
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
var ret = clearUrl(requestDetails);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To prevent long loading on data urls
|
|
||||||
* we will check here for data urls.
|
|
||||||
*
|
|
||||||
* @type {requestDetails}
|
|
||||||
* @return {boolean}
|
|
||||||
*/
|
|
||||||
function isDataURL(requestDetails) {
|
|
||||||
var s = requestDetails.url;
|
|
||||||
|
|
||||||
return s.substring(0,4) == "data";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call by each Request and checking the url.
|
|
||||||
*
|
|
||||||
* @type {Array}
|
|
||||||
*/
|
|
||||||
browser.webRequest.onBeforeRequest.addListener(
|
|
||||||
promise,
|
|
||||||
{urls: ["<all_urls>"], types: getData("types")},
|
|
||||||
["blocking"]
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save every minute the temporary data to the disk.
|
|
||||||
*/
|
|
||||||
setInterval(saveOnExit, 60000);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the badged status from the browser storage and put the value
|
|
||||||
* into a local variable.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function setBadgedStatus()
|
|
||||||
{
|
|
||||||
if(!checkOSAndroid() && storage.badgedStatus){
|
|
||||||
browser.browserAction.setBadgeBackgroundColor({
|
|
||||||
'color': '#'+storage.badged_color
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change the icon.
|
|
||||||
*/
|
|
||||||
function changeIcon()
|
|
||||||
{
|
|
||||||
if(storage.globalStatus){
|
|
||||||
browser.browserAction.setIcon({path: "img/clearurls.svg"});
|
|
||||||
} else{
|
|
||||||
browser.browserAction.setIcon({path: "img/clearurls_gray.svg"});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if it is an android device.
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
function checkOSAndroid()
|
|
||||||
{
|
|
||||||
if(os == "android")
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increase by {number} the GlobalURLCounter
|
|
||||||
* @param {int} number
|
|
||||||
*/
|
|
||||||
function increaseGlobalURLCounter(number)
|
|
||||||
{
|
|
||||||
if(storage.statisticsStatus)
|
|
||||||
{
|
|
||||||
storage.globalurlcounter += number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increase by one the URLCounter
|
|
||||||
*/
|
|
||||||
function increaseURLCounter()
|
|
||||||
{
|
|
||||||
if(storage.statisticsStatus)
|
|
||||||
{
|
|
||||||
storage.globalCounter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the storage variable to the disk.
|
|
||||||
*/
|
|
||||||
function saveOnExit()
|
|
||||||
{
|
|
||||||
var json = {};
|
|
||||||
|
|
||||||
Object.entries(storage).forEach(([key, value]) => {
|
|
||||||
switch (key) {
|
|
||||||
case "ClearURLsData":
|
|
||||||
case "log":
|
|
||||||
json[key] = JSON.stringify(value);
|
|
||||||
break;
|
|
||||||
case "types":
|
|
||||||
json[key] = value.toString();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
json[key] = value;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
console.log(translate('core_save_on_disk'));
|
|
||||||
browser.storage.local.set(json);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save the value under the key on the disk.
|
|
||||||
* @param {String} key
|
|
||||||
* @param {Object} value
|
|
||||||
*/
|
|
||||||
function saveOnDisk(key, value)
|
|
||||||
{
|
|
||||||
browser.storage.local.set({key: value});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve everything and save on the RAM.
|
|
||||||
*/
|
|
||||||
function getDataFromDisk()
|
|
||||||
{
|
|
||||||
browser.storage.local.get().then(start, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the value under the key.
|
|
||||||
* @param {String} key
|
|
||||||
* @return {Object}
|
|
||||||
*/
|
|
||||||
function getData(key)
|
|
||||||
{
|
|
||||||
return storage[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Save the value under the key on the RAM.
|
|
||||||
* @param {String} key
|
|
||||||
* @param {Object} value
|
|
||||||
*/
|
|
||||||
function setData(key, value)
|
|
||||||
{
|
|
||||||
switch (key) {
|
|
||||||
case "ClearURLsData":
|
|
||||||
case "log":
|
|
||||||
storage[key] = JSON.parse(value);
|
|
||||||
break;
|
|
||||||
case "hashURL":
|
|
||||||
case "ruleURL":
|
|
||||||
storage[key] = replaceOldURLs(value);
|
|
||||||
break;
|
|
||||||
case "types":
|
|
||||||
storage[key] = value.split(',');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
storage[key] = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Translate a string with the i18n API.
|
|
||||||
*
|
|
||||||
* @param {string} string Name of the attribute used for localization
|
|
||||||
*/
|
|
||||||
function translate(string)
|
|
||||||
{
|
|
||||||
return browser.i18n.getMessage(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Write error on console.
|
|
||||||
*/
|
|
||||||
function error()
|
|
||||||
{
|
|
||||||
console.log(translate('core_error'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set default values, if the storage is empty.
|
|
||||||
* @param {Object} items
|
|
||||||
*/
|
|
||||||
function initStorage(items)
|
|
||||||
{
|
|
||||||
initSettings();
|
|
||||||
|
|
||||||
if(!isEmpty(items)) {
|
|
||||||
Object.entries(items).forEach(([key, value]) => {
|
|
||||||
setData(key, value);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set default values for the settings.
|
|
||||||
*/
|
|
||||||
function initSettings()
|
|
||||||
{
|
|
||||||
storage.ClearURLsData = [];
|
|
||||||
storage.dataHash = "";
|
|
||||||
storage.badgedStatus = true;
|
|
||||||
storage.globalStatus = true;
|
|
||||||
storage.globalurlcounter = 0;
|
|
||||||
storage.globalCounter = 0;
|
|
||||||
storage.hashStatus = "error";
|
|
||||||
storage.loggingStatus = false;
|
|
||||||
storage.log = {"log": []};
|
|
||||||
storage.statisticsStatus = true;
|
|
||||||
storage.badged_color = "ffa500";
|
|
||||||
storage.hashURL = "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/rules.hash";
|
|
||||||
storage.ruleURL = "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/data.json";
|
|
||||||
storage.types = ["main_frame", "sub_frame", "xmlhttprequest"];
|
|
||||||
storage.reportServer = "https://clearurls.xn--rb-fka.it";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reloads the extension.
|
|
||||||
*/
|
|
||||||
function reload()
|
|
||||||
{
|
|
||||||
browser.runtime.reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace the old GitHub URLs with the
|
|
||||||
* new GitLab URLs.
|
|
||||||
*/
|
|
||||||
function replaceOldURLs(url)
|
|
||||||
{
|
|
||||||
switch (url) {
|
|
||||||
case "https://raw.githubusercontent.com/KevinRoebert/ClearUrls/master/data/rules.hash?flush_cache=true":
|
|
||||||
return "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/rules.hash";
|
|
||||||
case "https://raw.githubusercontent.com/KevinRoebert/ClearUrls/master/data/data.json?flush_cache=true":
|
|
||||||
return "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/data.json";
|
|
||||||
default:
|
|
||||||
return url;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if an object is empty.
|
|
||||||
* @param {Object} obj
|
|
||||||
* @return {Boolean}
|
|
||||||
*/
|
|
||||||
function isEmpty(obj)
|
|
||||||
{
|
|
||||||
return (Object.getOwnPropertyNames(obj).length === 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the current URL.
|
|
||||||
* @return {String} [description]
|
|
||||||
*/
|
|
||||||
function getCurrentURL()
|
|
||||||
{
|
|
||||||
return currentURL;
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
body {
|
|
||||||
font-size: 13px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.small-version {
|
|
||||||
font-size: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-header {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.col-sm-1 {
|
|
||||||
margin-top: -10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#body-popup {
|
|
||||||
width: 200px;
|
|
||||||
}
|
|
|
@ -1,39 +1,39 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "ClearURLs",
|
"name": "ClearURLs",
|
||||||
"version": "1.3.3.14",
|
"version": "1.5.2",
|
||||||
"author": "Kevin R.",
|
"author": "Kevin R.",
|
||||||
"description": "Remove tracking elements form URLs.",
|
"description": "Remove tracking elements form URLs.",
|
||||||
"homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",
|
"homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"icons": {
|
"icons": {
|
||||||
"16": "img/clearurls.png",
|
"16": "img/clearurls.svg",
|
||||||
"19": "img/clearurls.png",
|
"19": "img/clearurls.svg",
|
||||||
"20": "img/clearurls.png",
|
"20": "img/clearurls.svg",
|
||||||
"24": "img/clearurls.png",
|
"24": "img/clearurls.svg",
|
||||||
"30": "img/clearurls.png",
|
"30": "img/clearurls.svg",
|
||||||
"32": "img/clearurls.png",
|
"32": "img/clearurls.svg",
|
||||||
"38": "img/clearurls.png",
|
"38": "img/clearurls.svg",
|
||||||
"48": "img/clearurls.png",
|
"48": "img/clearurls.svg",
|
||||||
"64": "img/clearurls.png",
|
"64": "img/clearurls.svg",
|
||||||
"96": "img/clearurls.png",
|
"96": "img/clearurls.svg",
|
||||||
"128": "img/clearurls.png"
|
"128": "img/clearurls.svg"
|
||||||
|
|
||||||
},
|
},
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"browser_style": true,
|
"browser_style": true,
|
||||||
"default_icon": {
|
"default_icon": {
|
||||||
"16": "img/clearurls.png",
|
"16": "img/clearurls.svg",
|
||||||
"19": "img/clearurls.png",
|
"19": "img/clearurls.svg",
|
||||||
"20": "img/clearurls.png",
|
"20": "img/clearurls.svg",
|
||||||
"24": "img/clearurls.png",
|
"24": "img/clearurls.svg",
|
||||||
"30": "img/clearurls.png",
|
"30": "img/clearurls.svg",
|
||||||
"32": "img/clearurls.png",
|
"32": "img/clearurls.svg",
|
||||||
"38": "img/clearurls.png",
|
"38": "img/clearurls.svg",
|
||||||
"48": "img/clearurls.png",
|
"48": "img/clearurls.svg",
|
||||||
"64": "img/clearurls.png",
|
"64": "img/clearurls.svg",
|
||||||
"96": "img/clearurls.png",
|
"96": "img/clearurls.svg",
|
||||||
"128": "img/clearurls.png"
|
"128": "img/clearurls.svg"
|
||||||
|
|
||||||
},
|
},
|
||||||
"default_title": "ClearURLs Add-on",
|
"default_title": "ClearURLs Add-on",
|
||||||
|
@ -45,13 +45,17 @@
|
||||||
"webRequest",
|
"webRequest",
|
||||||
"webRequestBlocking",
|
"webRequestBlocking",
|
||||||
"storage",
|
"storage",
|
||||||
"tabs"
|
"tabs",
|
||||||
|
"unlimitedStorage"
|
||||||
],
|
],
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
"browser-polyfill.js",
|
"browser-polyfill.js",
|
||||||
"external_js/jquery-3.2.1.min.js",
|
"external_js/jquery-3.2.1.min.js",
|
||||||
"external_js/sha256.jquery.js",
|
"external_js/sha256.jquery.js",
|
||||||
|
"core_js/message_handler.js",
|
||||||
|
"core_js/tools.js",
|
||||||
|
"core_js/storage.js",
|
||||||
"clearurls.js"
|
"clearurls.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
global.browser = mod.exports;
|
global.browser = mod.exports;
|
||||||
}
|
}
|
||||||
})(this, function (module) {
|
})(this, function (module) {
|
||||||
/* webextension-polyfill - v0.3.1 - Tue Aug 21 2018 10:09:34 */
|
/* webextension-polyfill - v0.4.0 - Wed Feb 06 2019 11:58:31 */
|
||||||
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
||||||
/* vim: set sts=2 sw=2 et tw=80: */
|
/* vim: set sts=2 sw=2 et tw=80: */
|
||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
// contents of a function until the first time it's called, and since it will
|
// contents of a function until the first time it's called, and since it will
|
||||||
// never actually need to be called, this allows the polyfill to be included
|
// never actually need to be called, this allows the polyfill to be included
|
||||||
// in Firefox nearly for free.
|
// in Firefox nearly for free.
|
||||||
const wrapAPIs = () => {
|
const wrapAPIs = extensionAPIs => {
|
||||||
// NOTE: apiMetadata is associated to the content of the api-metadata.json file
|
// NOTE: apiMetadata is associated to the content of the api-metadata.json file
|
||||||
// at build time by replacing the following "include" with the content of the
|
// at build time by replacing the following "include" with the content of the
|
||||||
// JSON file.
|
// JSON file.
|
||||||
|
@ -241,7 +241,8 @@
|
||||||
"inspectedWindow": {
|
"inspectedWindow": {
|
||||||
"eval": {
|
"eval": {
|
||||||
"minArgs": 1,
|
"minArgs": 1,
|
||||||
"maxArgs": 2
|
"maxArgs": 2,
|
||||||
|
"singleCallbackArg": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"panels": {
|
"panels": {
|
||||||
|
@ -763,9 +764,9 @@
|
||||||
*/
|
*/
|
||||||
const makeCallback = (promise, metadata) => {
|
const makeCallback = (promise, metadata) => {
|
||||||
return (...callbackArgs) => {
|
return (...callbackArgs) => {
|
||||||
if (chrome.runtime.lastError) {
|
if (extensionAPIs.runtime.lastError) {
|
||||||
promise.reject(chrome.runtime.lastError);
|
promise.reject(extensionAPIs.runtime.lastError);
|
||||||
} else if (metadata.singleCallbackArg || callbackArgs.length <= 1) {
|
} else if (metadata.singleCallbackArg || callbackArgs.length <= 1 && metadata.singleCallbackArg !== false) {
|
||||||
promise.resolve(callbackArgs[0]);
|
promise.resolve(callbackArgs[0]);
|
||||||
} else {
|
} else {
|
||||||
promise.resolve(callbackArgs);
|
promise.resolve(callbackArgs);
|
||||||
|
@ -1110,14 +1111,14 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
const wrappedSendMessageCallback = ({ reject, resolve }, reply) => {
|
const wrappedSendMessageCallback = ({ reject, resolve }, reply) => {
|
||||||
if (chrome.runtime.lastError) {
|
if (extensionAPIs.runtime.lastError) {
|
||||||
// Detect when none of the listeners replied to the sendMessage call and resolve
|
// Detect when none of the listeners replied to the sendMessage call and resolve
|
||||||
// the promise to undefined as in Firefox.
|
// the promise to undefined as in Firefox.
|
||||||
// See https://github.com/mozilla/webextension-polyfill/issues/130
|
// See https://github.com/mozilla/webextension-polyfill/issues/130
|
||||||
if (chrome.runtime.lastError.message === CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE) {
|
if (extensionAPIs.runtime.lastError.message === CHROME_SEND_MESSAGE_CALLBACK_NO_RESPONSE_MESSAGE) {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
reject(chrome.runtime.lastError);
|
reject(extensionAPIs.runtime.lastError);
|
||||||
}
|
}
|
||||||
} else if (reply && reply.__mozWebExtensionPolyfillReject__) {
|
} else if (reply && reply.__mozWebExtensionPolyfillReject__) {
|
||||||
// Convert back the JSON representation of the error into
|
// Convert back the JSON representation of the error into
|
||||||
|
@ -1173,14 +1174,14 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return wrapObject(chrome, staticWrappers, apiMetadata);
|
return wrapObject(extensionAPIs, staticWrappers, apiMetadata);
|
||||||
};
|
};
|
||||||
|
|
||||||
// The build process adds a UMD wrapper around this file, which makes the
|
// The build process adds a UMD wrapper around this file, which makes the
|
||||||
// `module` variable available.
|
// `module` variable available.
|
||||||
module.exports = wrapAPIs(); // eslint-disable-line no-undef
|
module.exports = wrapAPIs(chrome);
|
||||||
} else {
|
} else {
|
||||||
module.exports = browser; // eslint-disable-line no-undef
|
module.exports = browser;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//# sourceMappingURL=browser-polyfill.js.map
|
//# sourceMappingURL=browser-polyfill.js.map
|
||||||
|
|
|
@ -36,7 +36,7 @@ function start()
|
||||||
/**
|
/**
|
||||||
* Save OS Version
|
* Save OS Version
|
||||||
*/
|
*/
|
||||||
browser.runtime.getPlatformInfo(function(info) {
|
chrome.runtime.getPlatformInfo(function(info) {
|
||||||
os = info.os;
|
os = info.os;
|
||||||
changeIcon();
|
changeIcon();
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ function handleMessage(request, sender, sendResponse)
|
||||||
{
|
{
|
||||||
var response = fn.apply(null, request.params);
|
var response = fn.apply(null, request.params);
|
||||||
|
|
||||||
sendResponse({response});
|
return Promise.resolve({response});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,27 +35,60 @@ var currentURL;
|
||||||
async function getData()
|
async function getData()
|
||||||
{
|
{
|
||||||
await browser.runtime.sendMessage({
|
await browser.runtime.sendMessage({
|
||||||
function: "getEntireData",
|
function: "getData",
|
||||||
|
params: ["globalCounter"]
|
||||||
|
}).then((data) => {
|
||||||
|
globalCounter = data.response;
|
||||||
|
});
|
||||||
|
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
function: "getData",
|
||||||
|
params: ["globalurlcounter"]
|
||||||
|
}).then((data) => {
|
||||||
|
globalurlcounter = data.response;
|
||||||
|
});
|
||||||
|
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
function: "getData",
|
||||||
|
params: ["globalStatus"]
|
||||||
|
}).then((data) => {
|
||||||
|
globalStatus = data.response;
|
||||||
|
});
|
||||||
|
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
function: "getData",
|
||||||
|
params: ["badgedStatus"]
|
||||||
|
}).then((data) => {
|
||||||
|
badgedStatus = data.response;
|
||||||
|
});
|
||||||
|
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
function: "getData",
|
||||||
|
params: ["hashStatus"]
|
||||||
|
}).then((data) => {
|
||||||
|
hashStatus = data.response;
|
||||||
|
});
|
||||||
|
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
function: "getData",
|
||||||
|
params: ["loggingStatus"]
|
||||||
|
}).then((data) => {
|
||||||
|
loggingStatus = data.response;
|
||||||
|
});
|
||||||
|
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
function: "getData",
|
||||||
|
params: ["statisticsStatus"]
|
||||||
|
}).then((data) => {
|
||||||
|
statisticsStatus = data.response;
|
||||||
|
});
|
||||||
|
|
||||||
|
await browser.runtime.sendMessage({
|
||||||
|
function: "getCurrentURL",
|
||||||
params: []
|
params: []
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
data = data.response;
|
currentURL = data.response;
|
||||||
globalCounter = data.globalCounter;
|
});
|
||||||
globalurlcounter = data.globalurlcounter;
|
|
||||||
globalStatus = data.globalStatus;
|
|
||||||
badgedStatus = data.badgedStatus;
|
|
||||||
hashStatus = data.hashStatus;
|
|
||||||
loggingStatus = data.loggingStatus;
|
|
||||||
statisticsStatus = data.statisticsStatus;
|
|
||||||
|
|
||||||
browser.runtime.sendMessage({
|
|
||||||
function: "getCurrentURL",
|
|
||||||
params: []
|
|
||||||
}).then((data) => {
|
|
||||||
currentURL = data.response;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}, handleError);
|
|
||||||
}, handleError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
/*
|
/*
|
||||||
* ClearURLs
|
* ClearURLs
|
||||||
* Copyright (c) 2017-2019 Kevin Röbert
|
* Copyright (c) 2017-2019 Kevin Röbert
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* 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/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*jshint esversion: 6 */
|
/*jshint esversion: 6 */
|
||||||
/*
|
/*
|
||||||
* This script is responsible for the storage.
|
* This script is responsible for the storage.
|
||||||
*/
|
*/
|
||||||
var storage = [];
|
var storage = [];
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ function saveOnDisk(key, value)
|
||||||
*/
|
*/
|
||||||
function getDataFromDisk()
|
function getDataFromDisk()
|
||||||
{
|
{
|
||||||
browser.storage.local.get().then(initStorage, error);
|
browser.storage.local.get(null).then(initStorage, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,9 +75,9 @@ function getData(key)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the entire storage object.
|
* Return the entire storage object.
|
||||||
* @return {Object}
|
* @return {Object}
|
||||||
*/
|
*/
|
||||||
function getEntireData()
|
function getEntireData()
|
||||||
{
|
{
|
||||||
return storage;
|
return storage;
|
||||||
|
@ -152,8 +152,13 @@ function initSettings()
|
||||||
storage.badged_color = "ffa500";
|
storage.badged_color = "ffa500";
|
||||||
storage.hashURL = "https://gitlab.com/KevinRoebert/ClearUrls/-/jobs/artifacts/master/raw/rules.min.hash?job=hash%20rules";
|
storage.hashURL = "https://gitlab.com/KevinRoebert/ClearUrls/-/jobs/artifacts/master/raw/rules.min.hash?job=hash%20rules";
|
||||||
storage.ruleURL = "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/data.min.json";
|
storage.ruleURL = "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/data.min.json";
|
||||||
storage.types = ["font", "image", "imageset", "main_frame", "media", "object", "object_subrequest", "other", "script", "stylesheet", "sub_frame", "websocket", "xbl", "xml_dtd", "xmlhttprequest", "xslt"];
|
|
||||||
storage.reportServer = "https://clearurls.xn--rb-fka.it";
|
storage.reportServer = "https://clearurls.xn--rb-fka.it";
|
||||||
|
|
||||||
|
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"];
|
||||||
|
} else if (getBrowser() === "Chrome") {
|
||||||
|
storage.types = ["main_frame", "sub_frame", "stylesheet", "script", "image", "font", "object", "xmlhttprequest", "ping", "csp_report", "media", "websocket", "other"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -69,7 +69,7 @@ function reload()
|
||||||
*/
|
*/
|
||||||
function checkOSAndroid()
|
function checkOSAndroid()
|
||||||
{
|
{
|
||||||
browser.runtime.getPlatformInfo().then(function(info) {
|
chrome.runtime.getPlatformInfo(function(info) {
|
||||||
os = info.os;
|
os = info.os;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -207,3 +207,14 @@ function getCurrentURL()
|
||||||
{
|
{
|
||||||
return currentURL;
|
return currentURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check for browser.
|
||||||
|
*/
|
||||||
|
function getBrowser() {
|
||||||
|
if(typeof InstallTrigger !== 'undefined') {
|
||||||
|
return "Firefox";
|
||||||
|
} else {
|
||||||
|
return "Chrome";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,10 @@ body {
|
||||||
margin-top: -10px;
|
margin-top: -10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#body-popup {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
#donate {
|
#donate {
|
||||||
transition: 0.3s;
|
transition: 0.3s;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "ClearURLs",
|
"name": "ClearURLs",
|
||||||
"version": "1.5.1.6a",
|
"version": "1.5.2",
|
||||||
"author": "Kevin R.",
|
"author": "Kevin R.",
|
||||||
"description": "Remove tracking elements form URLs.",
|
"description": "Remove tracking elements form URLs.",
|
||||||
"homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",
|
"homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",
|
||||||
|
@ -58,10 +58,10 @@
|
||||||
"browser-polyfill.js",
|
"browser-polyfill.js",
|
||||||
"external_js/jquery-3.2.1.min.js",
|
"external_js/jquery-3.2.1.min.js",
|
||||||
"external_js/sha256.jquery.js",
|
"external_js/sha256.jquery.js",
|
||||||
"clearurls.js",
|
"core_js/message_handler.js",
|
||||||
"core_js/storage.js",
|
"core_js/tools.js",
|
||||||
"core_js/tools.js",
|
"core_js/storage.js",
|
||||||
"core_js/message_handler.js"
|
"clearurls.js"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
|
|
BIN
promotion/screens/Popup_1.5.2.png
Normal file
BIN
promotion/screens/Popup_1.5.2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 44 KiB |
BIN
promotion/screens/Popup_1.5.2_chrome_store.png
Normal file
BIN
promotion/screens/Popup_1.5.2_chrome_store.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 64 KiB |
Loading…
Reference in New Issue
Block a user