mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-17 14:45:37 +07:00
Compare commits
11 Commits
m3-migrati
...
whitelist
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
08de228cc5 | ||
|
|
fcbe2abfdd | ||
|
|
81eb931e02 | ||
|
|
da90e259bb | ||
|
|
6a63859635 | ||
|
|
e86654ed29 | ||
|
|
deec80b763 | ||
|
|
7370e09fd7 | ||
|
|
99b96bcfce | ||
|
|
897c7dc67b | ||
|
|
dce06a7f47 |
@@ -28,8 +28,6 @@ bundle addon:
|
|||||||
stage: build
|
stage: build
|
||||||
script:
|
script:
|
||||||
- zip ClearURLs -r -FS clearurls.js browser-polyfill.js manifest.json img/* external_js/* html/* core_js/* css/* fonts/* _locales/*
|
- zip ClearURLs -r -FS clearurls.js browser-polyfill.js manifest.json img/* external_js/* html/* core_js/* css/* fonts/* _locales/*
|
||||||
only:
|
|
||||||
- master
|
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- ClearURLs.zip
|
- ClearURLs.zip
|
||||||
@@ -55,6 +53,8 @@ pages:
|
|||||||
- sha256sum public/data/data.min.json | awk '{print $1}' > public/data/rules.min.hash
|
- sha256sum public/data/data.min.json | awk '{print $1}' > public/data/rules.min.hash
|
||||||
- node build_tools/minifyDataJSON.js "public/data/data.min.json" "public/data/data.minify.json"
|
- node build_tools/minifyDataJSON.js "public/data/data.min.json" "public/data/data.minify.json"
|
||||||
- sha256sum public/data/data.minify.json | awk '{print $1}' > public/data/rules.minify.hash
|
- sha256sum public/data/data.minify.json | awk '{print $1}' > public/data/rules.minify.hash
|
||||||
|
only:
|
||||||
|
- master
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
|
|||||||
@@ -87,6 +87,14 @@
|
|||||||
"message": "Show numbers of cleaned urls",
|
"message": "Show numbers of cleaned urls",
|
||||||
"description": "This string is used as title for the badges switch button on the popup page."
|
"description": "This string is used as title for the badges switch button on the popup page."
|
||||||
},
|
},
|
||||||
|
"popup_html_configs_whitelist_button_add": {
|
||||||
|
"message": "Whitelist Site",
|
||||||
|
"description": "This string is used as name for the whitelist button on the popup page."
|
||||||
|
},
|
||||||
|
"popup_html_configs_whitelist_button_remove": {
|
||||||
|
"message": "Remove from Whitelist",
|
||||||
|
"description": "This string is used as name for the whitelist button on the popup page."
|
||||||
|
},
|
||||||
"popup_html_statistics_head": {
|
"popup_html_statistics_head": {
|
||||||
"message": "Statistics",
|
"message": "Statistics",
|
||||||
"description": "This string is used as title for the statistics on the popup page."
|
"description": "This string is used as title for the statistics on the popup page."
|
||||||
@@ -179,6 +187,10 @@
|
|||||||
"message": "The url to the rules.hash file (hash)",
|
"message": "The url to the rules.hash file (hash)",
|
||||||
"description": "This string is used as name for the rule.hash url label."
|
"description": "This string is used as name for the rule.hash url label."
|
||||||
},
|
},
|
||||||
|
"setting_whitelist_list_label": {
|
||||||
|
"message": "Whitelisted sites",
|
||||||
|
"description": "This string is used as name for the whitelisted sites list label."
|
||||||
|
},
|
||||||
"setting_types_label": {
|
"setting_types_label": {
|
||||||
"message": "<a href='https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType' target='_blank'>Request types</a> (expert level)",
|
"message": "<a href='https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest/ResourceType' target='_blank'>Request types</a> (expert level)",
|
||||||
"description": "This string is used as name for the types label."
|
"description": "This string is used as name for the types label."
|
||||||
|
|||||||
19
clearurls.js
19
clearurls.js
@@ -47,6 +47,19 @@ function removeFieldsFormURL(provider, pureUrl, quiet = false, request = null) {
|
|||||||
let rawRules = provider.getRawRules();
|
let rawRules = provider.getRawRules();
|
||||||
let urlObject = new URL(url);
|
let urlObject = new URL(url);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Skip whitelisted sites
|
||||||
|
*/
|
||||||
|
for (const site of storage.whitelist) {
|
||||||
|
if (url.indexOf(site) !== -1) {
|
||||||
|
return {
|
||||||
|
"changes": false,
|
||||||
|
"url": url,
|
||||||
|
"cancel": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (storage.localHostsSkipping && checkLocalURL(urlObject)) {
|
if (storage.localHostsSkipping && checkLocalURL(urlObject)) {
|
||||||
return {
|
return {
|
||||||
"changes": false,
|
"changes": false,
|
||||||
@@ -727,9 +740,3 @@ function start() {
|
|||||||
["blocking"]
|
["blocking"]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Must be asked after install
|
|
||||||
browser.permissions.request({
|
|
||||||
permissions: ["webRequest", "webRequestBlocking", "tabs", "scripting", "webNavigation"],
|
|
||||||
origins: ["<all_urls>"],
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ function increaseBadged(quiet = false, request) {
|
|||||||
checkOSAndroid().then((res) => {
|
checkOSAndroid().then((res) => {
|
||||||
if (!res) {
|
if (!res) {
|
||||||
if (storage.badgedStatus && !quiet) {
|
if (storage.badgedStatus && !quiet) {
|
||||||
browser.action.setBadgeText({text: (badges[tabId]).counter.toString(), tabId: tabId}).catch(handleError);
|
browser.browserAction.setBadgeText({text: (badges[tabId]).counter.toString(), tabId: tabId}).catch(handleError);
|
||||||
} else {
|
} else {
|
||||||
browser.action.setBadgeText({text: "", tabId: tabId}).catch(handleError);
|
browser.browserAction.setBadgeText({text: "", tabId: tabId}).catch(handleError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,9 +22,8 @@
|
|||||||
* and based on: https://github.com/mdn/webextensions-examples/tree/master/context-menu-copy-link-with-types
|
* and based on: https://github.com/mdn/webextensions-examples/tree/master/context-menu-copy-link-with-types
|
||||||
*/
|
*/
|
||||||
|
|
||||||
browser.runtime.onInstalled.addListener(contextMenuStart);
|
function contextMenuStart() {
|
||||||
|
if(storage.contextMenuEnabled) {
|
||||||
function contextMenuStart(details) {
|
|
||||||
browser.contextMenus.create({
|
browser.contextMenus.create({
|
||||||
id: "copy-link-to-clipboard",
|
id: "copy-link-to-clipboard",
|
||||||
title: translate("clipboard_copy_link"),
|
title: translate("clipboard_copy_link"),
|
||||||
@@ -34,17 +33,25 @@ function contextMenuStart(details) {
|
|||||||
browser.contextMenus.onClicked.addListener((info, tab) => {
|
browser.contextMenus.onClicked.addListener((info, tab) => {
|
||||||
if (info.menuItemId === "copy-link-to-clipboard") {
|
if (info.menuItemId === "copy-link-to-clipboard") {
|
||||||
const url = pureCleaning(info.linkUrl);
|
const url = pureCleaning(info.linkUrl);
|
||||||
|
const code = "copyToClipboard(" +
|
||||||
|
JSON.stringify(url)+");";
|
||||||
|
|
||||||
browser.scripting.executeScript({
|
browser.tabs.executeScript({
|
||||||
target: {
|
code: "typeof copyToClipboard === 'function';",
|
||||||
tabId: tab.id,
|
}).then((results) => {
|
||||||
allFrames: true
|
if (!results || results[0] !== true) {
|
||||||
},
|
return browser.tabs.executeScript(tab.id, {
|
||||||
func: (text) => navigator.clipboard.writeText(text),
|
file: "/external_js/clipboard-helper.js",
|
||||||
args: [
|
}).catch(handleError);
|
||||||
url
|
}
|
||||||
]
|
}).then(() => {
|
||||||
|
return browser.tabs.executeScript(tab.id, {
|
||||||
|
code,
|
||||||
|
});
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error("Failed to copy text: " + error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -27,6 +27,9 @@
|
|||||||
function injectFunction() {
|
function injectFunction() {
|
||||||
let ele = document.createElement('script');
|
let ele = document.createElement('script');
|
||||||
let s = document.getElementsByTagName('script')[0];
|
let s = document.getElementsByTagName('script')[0];
|
||||||
|
if (s === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ele.type = 'text/javascript';
|
ele.type = 'text/javascript';
|
||||||
ele.textContent = "Object.defineProperty(window, 'rwt', {" +
|
ele.textContent = "Object.defineProperty(window, 'rwt', {" +
|
||||||
|
|||||||
@@ -17,17 +17,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*jshint esversion: 6 */
|
/*jshint esversion: 6 */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This script is responsible for listen on history changes.
|
* This script is responsible for listen on history changes.
|
||||||
* This technique is often used to inject tracking code into the location bar,
|
* This technique is often used to inject tracking code into the location bar,
|
||||||
* because all feature events will use the updated URL.
|
* because all feature events will use the updated URL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
browser.webNavigation.onHistoryStateUpdated.addListener(historyCleaner);
|
|
||||||
|
|
||||||
function historyListenerStart() {
|
function historyListenerStart() {
|
||||||
|
if(storage.historyListenerEnabled) {
|
||||||
|
browser.webNavigation.onHistoryStateUpdated.addListener(historyCleaner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -38,24 +37,15 @@ function historyListenerStart() {
|
|||||||
* which is associated with the new history entry created by replaceState()
|
* which is associated with the new history entry created by replaceState()
|
||||||
*/
|
*/
|
||||||
function historyCleaner(details) {
|
function historyCleaner(details) {
|
||||||
if (storage.globalStatus && storage.historyListenerEnabled) {
|
if(storage.globalStatus) {
|
||||||
const urlBefore = details.url;
|
const urlBefore = details.url;
|
||||||
const urlAfter = pureCleaning(details.url);
|
const urlAfter = pureCleaning(details.url);
|
||||||
|
|
||||||
if(urlBefore !== urlAfter) {
|
if(urlBefore !== urlAfter) {
|
||||||
browser.scripting.executeScript({
|
browser.tabs.executeScript(details.tabId, {
|
||||||
target: {
|
frameId: details.frameId,
|
||||||
tabId: details.tabId,
|
code: 'history.replaceState(null,"",'+JSON.stringify(urlAfter)+');'
|
||||||
frameIds: [
|
}).then(() => {}, onError);
|
||||||
details.frameId
|
|
||||||
]
|
|
||||||
},
|
|
||||||
func: (url) => history.replaceState({state: null}, "", url),
|
|
||||||
args: [
|
|
||||||
urlAfter
|
|
||||||
]
|
|
||||||
}).then(() => {
|
|
||||||
}, onError);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,6 +62,34 @@ function changeStatistics()
|
|||||||
elTotal.textContent = totalCounter.toLocaleString();
|
elTotal.textContent = totalCounter.toLocaleString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the whitelist button text
|
||||||
|
*/
|
||||||
|
function setWhitelistText()
|
||||||
|
{
|
||||||
|
let element = document.getElementById('whitelist_btn');
|
||||||
|
let currentSite;
|
||||||
|
browser.tabs.query({active: true, currentWindow: true}, function(tabs) {
|
||||||
|
currentSite = tabs[0].url;
|
||||||
|
});
|
||||||
|
|
||||||
|
browser.runtime.sendMessage({
|
||||||
|
function: "getData",
|
||||||
|
params: ['whitelist']
|
||||||
|
}).then((data) => {
|
||||||
|
let siteFound = data.response.some(site => currentSite.indexOf(site) !== -1);
|
||||||
|
if (siteFound) {
|
||||||
|
element.classList.replace('btn-primary', 'btn-danger')
|
||||||
|
element.textContent = translate('popup_html_configs_whitelist_button_remove')
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value for the hashStatus on startUp.
|
* Set the value for the hashStatus on startUp.
|
||||||
*/
|
*/
|
||||||
@@ -155,6 +183,36 @@ function setSwitchButton(id, varname)
|
|||||||
element.checked = this[varname];
|
element.checked = this[varname];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds (or removes) the site the user is on to the whitelist
|
||||||
|
* Whitelisted sites do not get filtered
|
||||||
|
* @param {boolean} removeWl If true remove current site instead of adding
|
||||||
|
*/
|
||||||
|
function changeWhitelist(removeWl) {
|
||||||
|
let site;
|
||||||
|
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
|
||||||
|
});
|
||||||
|
browser.runtime.sendMessage({
|
||||||
|
function: "getData",
|
||||||
|
params: ['whitelist']
|
||||||
|
}).then((data) => {
|
||||||
|
let siteUrl = new URL(site)
|
||||||
|
let domain = siteUrl.hostname
|
||||||
|
if (removeWl) {
|
||||||
|
data.response = data.response.filter(wlSite => wlSite !== domain)
|
||||||
|
} else {
|
||||||
|
data.response.push(domain)
|
||||||
|
}
|
||||||
|
browser.runtime.sendMessage({
|
||||||
|
function: "setData",
|
||||||
|
params: ['whitelist', data.response]
|
||||||
|
}).then(() => {
|
||||||
|
setWhitelistText();
|
||||||
|
}).catch(handleError);
|
||||||
|
}).catch(handleError);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the global statistic
|
* Reset the global statistic
|
||||||
*/
|
*/
|
||||||
@@ -220,6 +278,7 @@ function setText()
|
|||||||
injectText('configs_switch_filter','popup_html_configs_switch_filter');
|
injectText('configs_switch_filter','popup_html_configs_switch_filter');
|
||||||
injectText('configs_head','popup_html_configs_head');
|
injectText('configs_head','popup_html_configs_head');
|
||||||
injectText('configs_switch_statistics','configs_switch_statistics');
|
injectText('configs_switch_statistics','configs_switch_statistics');
|
||||||
|
setWhitelistText();
|
||||||
document.getElementById('donate').title = translate('donate_button');
|
document.getElementById('donate').title = translate('donate_button');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ function save() {
|
|||||||
saveData("badged_color", pickr.getColor().toHEXA().toString())
|
saveData("badged_color", pickr.getColor().toHEXA().toString())
|
||||||
.then(() => saveData("ruleURL", document.querySelector('input[name=ruleURL]').value))
|
.then(() => saveData("ruleURL", document.querySelector('input[name=ruleURL]').value))
|
||||||
.then(() => saveData("hashURL", document.querySelector('input[name=hashURL]').value))
|
.then(() => saveData("hashURL", document.querySelector('input[name=hashURL]').value))
|
||||||
|
.then(() => saveData("whitelist", document.querySelector('input[name=whitelist]').value.split(',')))
|
||||||
.then(() => saveData("types", document.querySelector('input[name=types]').value))
|
.then(() => saveData("types", document.querySelector('input[name=types]').value))
|
||||||
.then(() => saveData("logLimit", Math.max(0, Math.min(5000, document.querySelector('input[name=logLimit]').value))))
|
.then(() => saveData("logLimit", Math.max(0, Math.min(5000, document.querySelector('input[name=logLimit]').value))))
|
||||||
.then(() => browser.runtime.sendMessage({
|
.then(() => browser.runtime.sendMessage({
|
||||||
@@ -122,6 +123,7 @@ function getData() {
|
|||||||
|
|
||||||
loadData("ruleURL")
|
loadData("ruleURL")
|
||||||
.then(() => loadData("hashURL"))
|
.then(() => loadData("hashURL"))
|
||||||
|
.then(() => loadData("whitelist"))
|
||||||
.then(() => loadData("types"))
|
.then(() => loadData("types"))
|
||||||
.then(() => loadData("logLimit"))
|
.then(() => loadData("logLimit"))
|
||||||
.then(logData => {
|
.then(logData => {
|
||||||
@@ -132,7 +134,8 @@ function getData() {
|
|||||||
}
|
}
|
||||||
}).catch(handleError);
|
}).catch(handleError);
|
||||||
|
|
||||||
loadData("historyListenerEnabled")
|
loadData("contextMenuEnabled")
|
||||||
|
.then(() => loadData("historyListenerEnabled"))
|
||||||
.then(() => loadData("localHostsSkipping"))
|
.then(() => loadData("localHostsSkipping"))
|
||||||
.then(() => loadData("referralMarketing"))
|
.then(() => loadData("referralMarketing"))
|
||||||
.then(() => loadData("domainBlocking"))
|
.then(() => loadData("domainBlocking"))
|
||||||
@@ -141,6 +144,7 @@ function getData() {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
changeSwitchButton("localHostsSkipping", "localHostsSkipping");
|
changeSwitchButton("localHostsSkipping", "localHostsSkipping");
|
||||||
changeSwitchButton("historyListenerEnabled", "historyListenerEnabled");
|
changeSwitchButton("historyListenerEnabled", "historyListenerEnabled");
|
||||||
|
changeSwitchButton("contextMenuEnabled", "contextMenuEnabled");
|
||||||
changeSwitchButton("referralMarketing", "referralMarketing");
|
changeSwitchButton("referralMarketing", "referralMarketing");
|
||||||
changeSwitchButton("domainBlocking", "domainBlocking");
|
changeSwitchButton("domainBlocking", "domainBlocking");
|
||||||
changeSwitchButton("pingBlocking", "pingBlocking");
|
changeSwitchButton("pingBlocking", "pingBlocking");
|
||||||
@@ -214,9 +218,11 @@ function setText() {
|
|||||||
document.getElementById('reset_settings_btn').setAttribute('title', translate('setting_html_reset_button_title'));
|
document.getElementById('reset_settings_btn').setAttribute('title', translate('setting_html_reset_button_title'));
|
||||||
document.getElementById('rule_url_label').textContent = translate('setting_rule_url_label');
|
document.getElementById('rule_url_label').textContent = translate('setting_rule_url_label');
|
||||||
document.getElementById('hash_url_label').textContent = translate('setting_hash_url_label');
|
document.getElementById('hash_url_label').textContent = translate('setting_hash_url_label');
|
||||||
|
document.getElementById('whitelist_list_label').textContent = translate('setting_whitelist_list_label');
|
||||||
document.getElementById('types_label').innerHTML = translate('setting_types_label');
|
document.getElementById('types_label').innerHTML = translate('setting_types_label');
|
||||||
document.getElementById('save_settings_btn').textContent = translate('settings_html_save_button');
|
document.getElementById('save_settings_btn').textContent = translate('settings_html_save_button');
|
||||||
document.getElementById('save_settings_btn').setAttribute('title', translate('settings_html_save_button_title'));
|
document.getElementById('save_settings_btn').setAttribute('title', translate('settings_html_save_button_title'));
|
||||||
|
injectText("context_menu_enabled", "context_menu_enabled");
|
||||||
document.getElementById('history_listener_enabled').innerHTML = translate('history_listener_enabled');
|
document.getElementById('history_listener_enabled').innerHTML = translate('history_listener_enabled');
|
||||||
injectText("local_hosts_skipping", "local_hosts_skipping");
|
injectText("local_hosts_skipping", "local_hosts_skipping");
|
||||||
document.getElementById('export_settings_btn_text').textContent = translate('setting_html_export_button');
|
document.getElementById('export_settings_btn_text').textContent = translate('setting_html_export_button');
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ function saveOnDisk(keys) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schedule to save a key to disk in 60 seconds.
|
* Schedule to save a key to disk in 30 seconds.
|
||||||
* @param {String} key
|
* @param {String} key
|
||||||
*/
|
*/
|
||||||
function deferSaveOnDisk(key) {
|
function deferSaveOnDisk(key) {
|
||||||
@@ -95,20 +95,13 @@ function deferSaveOnDisk(key) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.alarms.create("deferSaveOnDisk", {
|
setTimeout(function () {
|
||||||
delayInMinutes: 1
|
|
||||||
});
|
|
||||||
|
|
||||||
hasPendingSaves = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
browser.alarms.onAlarm.addListener(function (alarmInfo) {
|
|
||||||
if (alarmInfo.name === "deferSaveOnDisk") {
|
|
||||||
saveOnDisk(Array.from(pendingSaves));
|
saveOnDisk(Array.from(pendingSaves));
|
||||||
pendingSaves.clear();
|
pendingSaves.clear();
|
||||||
hasPendingSaves = false;
|
hasPendingSaves = false;
|
||||||
|
}, 30000);
|
||||||
|
hasPendingSaves = true;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start sequence for ClearURLs.
|
* Start sequence for ClearURLs.
|
||||||
@@ -122,6 +115,12 @@ function genesis() {
|
|||||||
|
|
||||||
//Set correct icon on startup
|
//Set correct icon on startup
|
||||||
changeIcon();
|
changeIcon();
|
||||||
|
|
||||||
|
// Start the context_menu
|
||||||
|
contextMenuStart();
|
||||||
|
|
||||||
|
// Start history listener
|
||||||
|
historyListenerStart();
|
||||||
}, handleError);
|
}, handleError);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -217,6 +216,8 @@ function initSettings() {
|
|||||||
storage.badged_color = "#ffa500";
|
storage.badged_color = "#ffa500";
|
||||||
storage.hashURL = "https://rules2.clearurls.xyz/rules.minify.hash";
|
storage.hashURL = "https://rules2.clearurls.xyz/rules.minify.hash";
|
||||||
storage.ruleURL = "https://rules2.clearurls.xyz/data.minify.json";
|
storage.ruleURL = "https://rules2.clearurls.xyz/data.minify.json";
|
||||||
|
storage.whitelist = []; // TODO: If we do whitelist per rule, this needs to be obj
|
||||||
|
storage.contextMenuEnabled = true;
|
||||||
storage.historyListenerEnabled = true;
|
storage.historyListenerEnabled = true;
|
||||||
storage.localHostsSkipping = true;
|
storage.localHostsSkipping = true;
|
||||||
storage.referralMarketing = false;
|
storage.referralMarketing = false;
|
||||||
|
|||||||
@@ -181,9 +181,9 @@ function changeIcon() {
|
|||||||
checkOSAndroid().then((res) => {
|
checkOSAndroid().then((res) => {
|
||||||
if (!res) {
|
if (!res) {
|
||||||
if (storage.globalStatus) {
|
if (storage.globalStatus) {
|
||||||
browser.action.setIcon({path: "img/clearurls_128x128.png"}).catch(handleError);
|
browser.browserAction.setIcon({path: "img/clearurls_128x128.png"}).catch(handleError);
|
||||||
} else {
|
} else {
|
||||||
browser.action.setIcon({path: "img/clearurls_gray_128x128.png"}).catch(handleError);
|
browser.browserAction.setIcon({path: "img/clearurls_gray_128x128.png"}).catch(handleError);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -200,13 +200,13 @@ function setBadgedStatus() {
|
|||||||
let color = storage.badged_color;
|
let color = storage.badged_color;
|
||||||
if (storage.badged_color.charAt(0) !== '#')
|
if (storage.badged_color.charAt(0) !== '#')
|
||||||
color = '#' + storage.badged_color;
|
color = '#' + storage.badged_color;
|
||||||
browser.action.setBadgeBackgroundColor({
|
browser.browserAction.setBadgeBackgroundColor({
|
||||||
'color': color
|
'color': color
|
||||||
}).catch(handleError);
|
}).catch(handleError);
|
||||||
|
|
||||||
// Works only in Firefox: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/action/setBadgeTextColor#Browser_compatibility
|
// Works only in Firefox: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/browserAction/setBadgeTextColor#Browser_compatibility
|
||||||
if (getBrowser() === "Firefox") {
|
if (getBrowser() === "Firefox") {
|
||||||
browser.action.setBadgeTextColor({
|
browser.browserAction.setBadgeTextColor({
|
||||||
color: "#FFFFFF"
|
color: "#FFFFFF"
|
||||||
}).catch(handleError);
|
}).catch(handleError);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,15 +24,12 @@
|
|||||||
*
|
*
|
||||||
* This watchdog restarts the whole Add-on, when the check fails.
|
* This watchdog restarts the whole Add-on, when the check fails.
|
||||||
*/
|
*/
|
||||||
|
const CHECK_INTERVAL = 60000;
|
||||||
const __dirtyURL = "https://clearurls.roebert.eu?utm_source=addon";
|
const __dirtyURL = "https://clearurls.roebert.eu?utm_source=addon";
|
||||||
const __cleanURL = new URL("https://clearurls.roebert.eu").toString();
|
const __cleanURL = new URL("https://clearurls.roebert.eu").toString();
|
||||||
|
|
||||||
browser.alarms.create("watchdog", {
|
setInterval(function() {
|
||||||
periodInMinutes: 1,
|
if(isStorageAvailable() && storage.globalStatus) {
|
||||||
});
|
|
||||||
|
|
||||||
browser.alarms.onAlarm.addListener(function (alarmInfo) {
|
|
||||||
if (alarmInfo.name === "watchdog" && isStorageAvailable() && storage.globalStatus) {
|
|
||||||
if(new URL(pureCleaning(__dirtyURL, true)).toString() !== __cleanURL) {
|
if(new URL(pureCleaning(__dirtyURL, true)).toString() !== __cleanURL) {
|
||||||
storage.watchDogErrorCount += 1;
|
storage.watchDogErrorCount += 1;
|
||||||
console.log(translate('watchdog', storage.watchDogErrorCount));
|
console.log(translate('watchdog', storage.watchDogErrorCount));
|
||||||
@@ -43,4 +40,4 @@ browser.alarms.onAlarm.addListener(function (alarmInfo) {
|
|||||||
saveOnExit();
|
saveOnExit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}, CHECK_INTERVAL);
|
||||||
|
|||||||
16
external_js/clipboard-helper.js
Normal file
16
external_js/clipboard-helper.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* Source: https://github.com/mdn/webextensions-examples/tree/master/context-menu-copy-link-with-types
|
||||||
|
*/
|
||||||
|
function copyToClipboard(text) {
|
||||||
|
function oncopy(event) {
|
||||||
|
document.removeEventListener("copy", oncopy, true);
|
||||||
|
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
event.clipboardData.setData("text/plain", text);
|
||||||
|
}
|
||||||
|
document.addEventListener("copy", oncopy, true);
|
||||||
|
|
||||||
|
document.execCommand("copy");
|
||||||
|
}
|
||||||
@@ -86,6 +86,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<label id="configs_switch_statistics"></label>
|
<label id="configs_switch_statistics"></label>
|
||||||
</label>
|
</label>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
<div class="text-center">
|
||||||
|
<button type="button" id="whitelist_btn" class="btn btn-primary btn-sm text-wrap"></button>
|
||||||
|
</div>
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -105,6 +105,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<input type="url" id="hashURL" value="" name="hashURL" class="form-control" />
|
<input type="url" id="hashURL" value="" name="hashURL" class="form-control" />
|
||||||
</p>
|
</p>
|
||||||
<br />
|
<br />
|
||||||
|
<p>
|
||||||
|
<label id="whitelist_list_label"></label><br />
|
||||||
|
<input type="text" id="whitelist" value="" name="whitelist" class="form-control" />
|
||||||
|
</p>
|
||||||
|
<br />
|
||||||
<p>
|
<p>
|
||||||
<label id="types_label"></label><br />
|
<label id="types_label"></label><br />
|
||||||
<input type="text" id="types" value="" name="types" class="form-control" />
|
<input type="text" id="types" value="" name="types" class="form-control" />
|
||||||
@@ -136,6 +141,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<span class="slider round"></span>
|
<span class="slider round"></span>
|
||||||
</label>
|
</label>
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
<label id="context_menu_enabled" style="font-weight: bold;"></label><br />
|
||||||
|
<label class="switch">
|
||||||
|
<input type="checkbox" id="contextMenuEnabled">
|
||||||
|
<span class="slider round"></span>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label id="referral_marketing_enabled" style="font-weight: bold;"></label><br />
|
<label id="referral_marketing_enabled" style="font-weight: bold;"></label><br />
|
||||||
<label class="switch">
|
<label class="switch">
|
||||||
|
|||||||
@@ -1,14 +1,12 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 2,
|
||||||
"name": "ClearURLs",
|
"name": "ClearURLs",
|
||||||
"version": "1.28.0",
|
"version": "1.27.0",
|
||||||
"author": "Kevin Roebert",
|
"author": "Kevin Roebert",
|
||||||
"description": "__MSG_extension_description__",
|
"description": "__MSG_extension_description__",
|
||||||
"homepage_url": "https://docs.clearurls.xyz",
|
"homepage_url": "https://docs.clearurls.xyz",
|
||||||
"default_locale": "en",
|
"default_locale": "en",
|
||||||
"content_security_policy": {
|
"content_security_policy": "script-src 'self'; object-src 'none'",
|
||||||
"extension_pages": "script-src 'self'; object-src 'none'"
|
|
||||||
},
|
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
"gecko": {
|
"gecko": {
|
||||||
"id": "{74145f27-f039-47ce-a470-a662b129930a}"
|
"id": "{74145f27-f039-47ce-a470-a662b129930a}"
|
||||||
@@ -27,7 +25,8 @@
|
|||||||
"96": "img/clearurls_96x96.png",
|
"96": "img/clearurls_96x96.png",
|
||||||
"128": "img/clearurls_128x128.png"
|
"128": "img/clearurls_128x128.png"
|
||||||
},
|
},
|
||||||
"action": {
|
"browser_action": {
|
||||||
|
"browser_style": true,
|
||||||
"default_icon": {
|
"default_icon": {
|
||||||
"16": "img/clearurls_16x16.png",
|
"16": "img/clearurls_16x16.png",
|
||||||
"19": "img/clearurls_19x19.png",
|
"19": "img/clearurls_19x19.png",
|
||||||
@@ -45,6 +44,7 @@
|
|||||||
"default_popup": "html/popup.html"
|
"default_popup": "html/popup.html"
|
||||||
},
|
},
|
||||||
"permissions": [
|
"permissions": [
|
||||||
|
"<all_urls>",
|
||||||
"webRequest",
|
"webRequest",
|
||||||
"webRequestBlocking",
|
"webRequestBlocking",
|
||||||
"storage",
|
"storage",
|
||||||
@@ -52,12 +52,7 @@
|
|||||||
"contextMenus",
|
"contextMenus",
|
||||||
"webNavigation",
|
"webNavigation",
|
||||||
"tabs",
|
"tabs",
|
||||||
"downloads",
|
"downloads"
|
||||||
"scripting",
|
|
||||||
"alarms"
|
|
||||||
],
|
|
||||||
"host_permissions": [
|
|
||||||
"<all_urls>"
|
|
||||||
],
|
],
|
||||||
"background": {
|
"background": {
|
||||||
"scripts": [
|
"scripts": [
|
||||||
|
|||||||
Reference in New Issue
Block a user