Version 1.3.3.1

I've updated the ClearURLs core, so that ClearURLs only cleans the fields from urls.

This means that ClearURLs can no longer examine all components of a URL and, if necessary, remove something, but only the so-called GET fields.

This restricts not hardly, since everything that is not a GET field is a part of the url (the path) and should not actually be removed.

However, because ClearURLs was able to remove these path elements, this problem came up again. Now ClearURLs can only remove GET fields and thus no longer destroy paths.

I hope that there are fewer problems now. Another little side effect of the change, ClearURLs is now working more efficiently.
This commit is contained in:
Kevin Röbert 2018-06-23 12:56:37 +02:00
parent b2b1c935c5
commit 349b645d88
2 changed files with 53 additions and 23 deletions

View File

@ -336,6 +336,8 @@ function start(items)
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;
@ -357,34 +359,50 @@ function start(items)
};
}
for (var i = 0; i < rules.length; i++) {
var beforReplace = url;
/**
* Only test for matches, if there are fields that can be cleaned.
*/
if(existsFields(url))
{
fields = url.replace(new RegExp(".*\\?", "i"), "");
url = url.replace(new RegExp(rules[i], "i"), "");
for (var i = 0; i < rules.length; i++) {
var beforReplace = fields;
if(beforReplace != url)
{
//Log the action
pushToLog(beforReplace, url, rules[i]);
fields = fields.replace(new RegExp(rules[i], "i"), "");
if(badges[tabid] == null)
if(beforReplace != fields)
{
badges[tabid] = 0;
}
//Log the action
pushToLog(domain+"?"+beforReplace, domain+"?"+fields, rules[i]);
increaseURLCounter();
if(!checkOSAndroid())
{
if(storage.badgedStatus) {
browser.browserAction.setBadgeText({text: (++badges[tabid]).toString(), tabId: tabid});
}
else
if(badges[tabid] == null)
{
browser.browserAction.setBadgeText({text: "", tabId: tabid});
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;
}
}
@ -417,8 +435,6 @@ function start(items)
"url": url,
"cancel": cancel
};
}
/**
@ -434,6 +450,19 @@ function start(items)
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.
@ -492,6 +521,7 @@ function start(items)
* a loop.
*/
if(result.changes){
console.log(result.url);
return {
redirectUrl: result.url
};

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "ClearURLs",
"version": "1.3.2.0",
"version": "1.3.3.1",
"author": "Kevin R.",
"description": "Remove tracking elements form URLs.",
"homepage_url": "https://gitlab.com/KevinRoebert/ClearUrls",