mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-16 06:05:37 +07:00
changes
This commit is contained in:
@@ -51,7 +51,7 @@ function removeFieldsFormURL(provider, pureUrl, quiet = false, request = null) {
|
|||||||
* Skip whitelisted sites
|
* Skip whitelisted sites
|
||||||
*/
|
*/
|
||||||
for (const site of storage.whitelist) {
|
for (const site of storage.whitelist) {
|
||||||
if (url.indexOf(site) != -1) {
|
if (url.indexOf(site) !== -1) {
|
||||||
return {
|
return {
|
||||||
"changes": false,
|
"changes": false,
|
||||||
"url": url,
|
"url": url,
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ function changeStatistics()
|
|||||||
function setWhitelistText()
|
function setWhitelistText()
|
||||||
{
|
{
|
||||||
let element = document.getElementById('whitelist_btn');
|
let element = document.getElementById('whitelist_btn');
|
||||||
let currentSite, siteFound;
|
let currentSite;
|
||||||
browser.tabs.query({active: true, currentWindow: true}, function(tabs) {
|
browser.tabs.query({active: true, currentWindow: true}, function(tabs) {
|
||||||
currentSite = tabs[0].url;
|
currentSite = tabs[0].url;
|
||||||
});
|
});
|
||||||
@@ -77,21 +77,15 @@ function setWhitelistText()
|
|||||||
function: "getData",
|
function: "getData",
|
||||||
params: ['whitelist']
|
params: ['whitelist']
|
||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
data.response.forEach(site => {
|
let siteFound = data.response.some(site => currentSite.indexOf(site) !== -1);
|
||||||
if (currentSite.indexOf(site) != -1) {
|
if (siteFound) {
|
||||||
siteFound = true
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (!siteFound) {
|
|
||||||
if (data.response.length != 0) {
|
|
||||||
element.classList.replace('btn-danger', 'btn-primary')
|
|
||||||
}
|
|
||||||
element.textContent = translate('popup_html_configs_whitelist_button_add')
|
|
||||||
document.getElementById('whitelist_btn').onclick = changeWhitelist;
|
|
||||||
} else {
|
|
||||||
element.classList.replace('btn-primary', 'btn-danger')
|
element.classList.replace('btn-primary', 'btn-danger')
|
||||||
element.textContent = translate('popup_html_configs_whitelist_button_remove')
|
element.textContent = translate('popup_html_configs_whitelist_button_remove')
|
||||||
document.getElementById('whitelist_btn').onclick = () => {changeWhitelist(true)};
|
document.getElementById('whitelist_btn').onclick = () => {changeWhitelist(true)};
|
||||||
|
} else {
|
||||||
|
element.classList.replace('btn-danger', 'btn-primary')
|
||||||
|
element.textContent = translate('popup_html_configs_whitelist_button_add')
|
||||||
|
document.getElementById('whitelist_btn').onclick = () => {changeWhitelist(false)};
|
||||||
}
|
}
|
||||||
}).catch(handleError);
|
}).catch(handleError);
|
||||||
}
|
}
|
||||||
@@ -192,12 +186,9 @@ function setSwitchButton(id, varname)
|
|||||||
/**
|
/**
|
||||||
* Adds (or removes) the site the user is on to the whitelist
|
* Adds (or removes) the site the user is on to the whitelist
|
||||||
* Whitelisted sites do not get filtered
|
* Whitelisted sites do not get filtered
|
||||||
* @param {boolean} remove If true remove current site instead of adding
|
* @param {boolean} removeWl If true remove current site instead of adding
|
||||||
*/
|
*/
|
||||||
function changeWhitelist(removeWl = false) {
|
function changeWhitelist(removeWl) {
|
||||||
if (removeWl != true) { // Handle click obj
|
|
||||||
removeWl = false
|
|
||||||
}
|
|
||||||
let site;
|
let site;
|
||||||
browser.tabs.query({active: true, currentWindow: true}, function(tabs) { // Couldn't figure out how to access currentUrl var
|
browser.tabs.query({active: true, currentWindow: true}, function(tabs) { // Couldn't figure out how to access currentUrl var
|
||||||
site = tabs[0].url; // So this is used instead
|
site = tabs[0].url; // So this is used instead
|
||||||
@@ -208,10 +199,10 @@ function changeWhitelist(removeWl = false) {
|
|||||||
}).then((data) => {
|
}).then((data) => {
|
||||||
let siteUrl = new URL(site)
|
let siteUrl = new URL(site)
|
||||||
let domain = siteUrl.hostname
|
let domain = siteUrl.hostname
|
||||||
if (removeWl == false) {
|
if (removeWl) {
|
||||||
data.response.push(domain)
|
data.response = data.response.filter(wlSite => wlSite !== domain)
|
||||||
} else {
|
} else {
|
||||||
data.response = data.response.filter(wlSite => wlSite != domain)
|
data.response.push(domain)
|
||||||
}
|
}
|
||||||
browser.runtime.sendMessage({
|
browser.runtime.sendMessage({
|
||||||
function: "setData",
|
function: "setData",
|
||||||
|
|||||||
Reference in New Issue
Block a user