91d46a7b70
- Added listener to the browser history to prevent tracking with the [history.pushState method](https://developer.mozilla.org/en-US/docs/Web/API/History_API) - Added webNavigation and tabs permissions, for the new feature - Added switches in settings to enable and disable the context menu entry and the history listener - Added tool to clean URLs, that was pasted into a textbox - Added icon for new tool to clean URLs - Fixed [#40](https://gitlab.com/KevinRoebert/ClearUrls/issues/40), see also https://curl.kevinroebert.de - Fixed [#103](https://gitlab.com/KevinRoebert/ClearUrls/issues/103), see also https://curl.kevinroebert.de - Changed clipboard-helper.js path to be absolute to prevent problems - Changed rewrite of old GitHub links to the new data.min.json and rules.min.hash - Config icon is now bigger and above the config label - Update Traditional Chinese Translation by [@yipinghuang](https://gitlab.com/yipinghuang) #161 #162 #157 #40 #103 #158
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
/*
|
|
* ClearURLs
|
|
* Copyright (c) 2017-2019 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 */
|
|
|
|
/**
|
|
* Cleans given links. Also do automatic redirection.
|
|
*
|
|
* @param {[type]} url url as string
|
|
* @return {Array} redirectUrl or none
|
|
*/
|
|
function pureCleaning(url) {
|
|
// The URL is already cleaned
|
|
if(lastVisited === url) {
|
|
return url;
|
|
}
|
|
|
|
var cleanURL = url;
|
|
|
|
for (var i = 0; i < providers.length; i++) {
|
|
var result = {
|
|
"changes": false,
|
|
"url": "",
|
|
"redirect": false,
|
|
"cancel": false
|
|
};
|
|
|
|
if(providers[i].matchURL(cleanURL))
|
|
{
|
|
result = removeFieldsFormURL(providers[i], cleanURL);
|
|
cleanURL = result.url;
|
|
}
|
|
|
|
if(result.redirect)
|
|
{
|
|
return result.url;
|
|
}
|
|
}
|
|
|
|
return cleanURL;
|
|
}
|