mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-15 21:55:36 +07:00
Version 1.8.0
This commit is contained in:
@@ -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