mirror of
https://gitlab.com/KevinRoebert/ClearUrls
synced 2025-12-16 14:15:36 +07:00
Compare commits
8 Commits
1d97d5df7b
...
9cba903db5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9cba903db5 | ||
|
|
d16a571d3a | ||
|
|
08de228cc5 | ||
|
|
fcbe2abfdd | ||
|
|
81eb931e02 | ||
|
|
da90e259bb | ||
|
|
6a63859635 | ||
|
|
e86654ed29 |
@@ -77,6 +77,7 @@ Please push your translation into the folder `_locales/{language code}/messages.
|
|||||||
* [Unalix](https://github.com/AmanoTeam/Unalix) small, dependency-free, fast Python package for removing tracking fields from URLs
|
* [Unalix](https://github.com/AmanoTeam/Unalix) small, dependency-free, fast Python package for removing tracking fields from URLs
|
||||||
* [Unalix-nim](https://github.com/AmanoTeam/Unalix-nim) small, dependency-free, fast Nim package and CLI tool for removing tracking fields from URLs
|
* [Unalix-nim](https://github.com/AmanoTeam/Unalix-nim) small, dependency-free, fast Nim package and CLI tool for removing tracking fields from URLs
|
||||||
* [UnalixAndroid](https://github.com/AmanoTeam/UnalixAndroid) simple Android app that removes link masking/tracking and optionally resolves shortened links
|
* [UnalixAndroid](https://github.com/AmanoTeam/UnalixAndroid) simple Android app that removes link masking/tracking and optionally resolves shortened links
|
||||||
|
* [pl-fe](https://github.com/mkljczk/pl-fe) is a Fediverse client which uses ClearURLs code to clean URLs from displayed posts and recommend cleaning URLs from created posts
|
||||||
|
|
||||||
## Recommended by...
|
## Recommended by...
|
||||||
* [ghacks-user.js](https://github.com/ghacksuserjs/ghacks-user.js/wiki/4.1-Extensions)
|
* [ghacks-user.js](https://github.com/ghacksuserjs/ghacks-user.js/wiki/4.1-Extensions)
|
||||||
@@ -112,4 +113,4 @@ We use some third-party scripts in our add-on. The authors and licenses are list
|
|||||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=ClearURLs/Addon&type=Date&theme=dark" />
|
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=ClearURLs/Addon&type=Date&theme=dark" />
|
||||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=ClearURLs/Addon&type=Date" />
|
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=ClearURLs/Addon&type=Date" />
|
||||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=ClearURLs/Addon&type=Date" />
|
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=ClearURLs/Addon&type=Date" />
|
||||||
</picture>
|
</picture>
|
||||||
|
|||||||
@@ -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."
|
||||||
|
|||||||
13
clearurls.js
13
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,
|
||||||
|
|||||||
@@ -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 => {
|
||||||
@@ -216,6 +218,7 @@ 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'));
|
||||||
|
|||||||
@@ -216,6 +216,7 @@ 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.contextMenuEnabled = true;
|
||||||
storage.historyListenerEnabled = true;
|
storage.historyListenerEnabled = true;
|
||||||
storage.localHostsSkipping = true;
|
storage.localHostsSkipping = true;
|
||||||
|
|||||||
@@ -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" />
|
||||||
|
|||||||
Reference in New Issue
Block a user