mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-16 06:05:37 +07:00
Version 1.8.0
This commit is contained in:
@@ -26,6 +26,10 @@
|
||||
*/
|
||||
function pureCleaning(url) {
|
||||
var cleanURL = url;
|
||||
var URLbeforeReplaceCount = countFields(url);
|
||||
|
||||
//Add Fields form Request to global url counter
|
||||
increaseGlobalURLCounter(URLbeforeReplaceCount);
|
||||
|
||||
for (var i = 0; i < providers.length; i++) {
|
||||
var result = {
|
||||
|
||||
@@ -110,8 +110,6 @@ function save()
|
||||
function: "reload",
|
||||
params: []
|
||||
}).then(handleResponse, handleError);
|
||||
|
||||
//location.reload();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,12 +157,17 @@ function getData()
|
||||
params: ["historyListenerEnabled"]
|
||||
}).then((data) => {
|
||||
handleResponseData(data, "historyListenerEnabled", "historyListenerEnabled");
|
||||
changeSwitchButton("contextMenuEnabled", "contextMenuEnabled");
|
||||
changeSwitchButton("historyListenerEnabled", "historyListenerEnabled");
|
||||
browser.runtime.sendMessage({
|
||||
function: "getData",
|
||||
params: ["localHostsSkipping"]
|
||||
}).then((data) => {
|
||||
handleResponseData(data, "localHostsSkipping", "localHostsSkipping");
|
||||
changeSwitchButton("contextMenuEnabled", "contextMenuEnabled");
|
||||
changeSwitchButton("historyListenerEnabled", "historyListenerEnabled");
|
||||
changeSwitchButton("localHostsSkipping", "localHostsSkipping");
|
||||
}, handleError);
|
||||
}, handleError);
|
||||
}, handleError);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,6 +187,7 @@ function setText()
|
||||
$('#save_settings_btn').prop('title', translate('settings_html_save_button_title'));
|
||||
injectText("context_menu_enabled", "context_menu_enabled");
|
||||
$('#history_listener_enabled').html(translate('history_listener_enabled'));
|
||||
injectText("local_hosts_skipping", "local_hosts_skipping");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -160,6 +160,7 @@ function initSettings()
|
||||
storage.ruleURL = "https://gitlab.com/KevinRoebert/ClearUrls/raw/master/data/data.min.json";
|
||||
storage.contextMenuEnabled = true;
|
||||
storage.historyListenerEnabled = true;
|
||||
storage.localHostsSkipping = true;
|
||||
|
||||
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"];
|
||||
|
||||
@@ -67,10 +67,10 @@ function reload()
|
||||
* Check if it is an android device.
|
||||
* @return bool
|
||||
*/
|
||||
function checkOSAndroid()
|
||||
async function checkOSAndroid()
|
||||
{
|
||||
if(os === undefined || os === null || os === "") {
|
||||
chrome.runtime.getPlatformInfo(function(info) {
|
||||
await chrome.runtime.getPlatformInfo(function(info) {
|
||||
os = info.os;
|
||||
});
|
||||
}
|
||||
@@ -84,6 +84,31 @@ function checkOSAndroid()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the host without port from an url.
|
||||
* @param {String} url URL as String
|
||||
* @return {Array} host as string
|
||||
*/
|
||||
function extractHost(url) {
|
||||
let parsed_url = new URL(url);
|
||||
|
||||
return parsed_url.hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the url has a local host.
|
||||
* @param {String} url URL as String
|
||||
* @return {boolean}
|
||||
*/
|
||||
function checkLocalURL(url) {
|
||||
let host = extractHost(url);
|
||||
|
||||
return ipRangeCheck(host, ["10.0.0.0/8", "172.16.0.0/12",
|
||||
"192.168.0.0/16", "100.64.0.0/10",
|
||||
"169.254.0.0/16", "127.0.0.1"])||
|
||||
host === 'localhost';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the number of parameters query strings.
|
||||
* @param {String} url URL as String
|
||||
@@ -225,13 +250,15 @@ function increaseURLCounter()
|
||||
*/
|
||||
function changeIcon()
|
||||
{
|
||||
if(!checkOSAndroid()) {
|
||||
if(storage.globalStatus){
|
||||
browser.browserAction.setIcon({path: "img/clearurls_128x128.png"});
|
||||
} else{
|
||||
browser.browserAction.setIcon({path: "img/clearurls_gray_128x128.png"});
|
||||
checkOSAndroid().then((res) => {
|
||||
if(!res) {
|
||||
if(storage.globalStatus){
|
||||
browser.browserAction.setIcon({path: "img/clearurls_128x128.png"});
|
||||
} else{
|
||||
browser.browserAction.setIcon({path: "img/clearurls_gray_128x128.png"});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,11 +268,13 @@ function changeIcon()
|
||||
*/
|
||||
function setBadgedStatus()
|
||||
{
|
||||
if(!checkOSAndroid() && storage.badgedStatus){
|
||||
browser.browserAction.setBadgeBackgroundColor({
|
||||
'color': '#'+storage.badged_color
|
||||
});
|
||||
}
|
||||
checkOSAndroid().then((res) => {
|
||||
if(!res && storage.badgedStatus) {
|
||||
browser.browserAction.setBadgeBackgroundColor({
|
||||
'color': '#'+storage.badged_color
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user