Update popup (domain to clear cookies)
This commit is contained in:
parent
352e2852e1
commit
e37fadb501
@ -214,8 +214,13 @@ function set_rules(sites, sites_updated, sites_custom) {
|
||||
if (rule.hasOwnProperty('block_regex')) {
|
||||
if (rule.block_regex instanceof RegExp)
|
||||
blockedRegexes[domain] = rule.block_regex;
|
||||
else
|
||||
blockedRegexes[domain] = new RegExp(rule.block_regex.replace('{domain}', domain.replace(/\./g, '\\.').replace(/(^\/|\/$)/g, '')));
|
||||
else {
|
||||
try {
|
||||
blockedRegexes[domain] = new RegExp(rule.block_regex.replace('{domain}', domain.replace(/\./g, '\\.').replace(/(^\/|\/$)/g, '')));
|
||||
} catch (e) {
|
||||
false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (rule.useragent) {
|
||||
switch (rule.useragent) {
|
||||
|
@ -4,6 +4,7 @@ Changelog Bypass Paywalls Clean - Chrome
|
||||
Post-release
|
||||
Add Mainichi Shimbun (Japan)
|
||||
Fix Bloomberg (quotes)
|
||||
Update popup (domain to clear cookies)
|
||||
|
||||
* v2.5.1.0 (2022-01-09)
|
||||
Add group Hearst Communications (local USA)
|
||||
|
@ -3,12 +3,26 @@ var ext_api = (typeof browser === 'object') ? browser : chrome;
|
||||
window.localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
|
||||
var cookie_domain = document.domain.replace(/^(www|amp(\d|html)?|m|wap)\./, '');
|
||||
var cookie_domain = getCookieDomain(document.domain);
|
||||
|
||||
// send domain to background.js (to clear cookies)
|
||||
ext_api.runtime.sendMessage({
|
||||
domain: cookie_domain
|
||||
});
|
||||
|
||||
function getCookieDomain(hostname) {
|
||||
let domain = hostname;
|
||||
let n = 0;
|
||||
let parts = hostname.split('.');
|
||||
let str = '_gd' + (new Date()).getTime();
|
||||
while (n < (parts.length - 1) && document.cookie.indexOf(str + '=' + str) == -1) {
|
||||
domain = parts.slice(-1 - (++n)).join('.');
|
||||
document.cookie = str + "=" + str + ";domain=" + domain + ";";
|
||||
}
|
||||
document.cookie = str + "=;expires=Thu, 01 Jan 1970 00:00:01 GMT;domain=" + domain + ";";
|
||||
return domain;
|
||||
}
|
||||
|
||||
var msg = "Cookies (and local storage) removed from " + cookie_domain;
|
||||
showMessage(msg, 2000);
|
||||
|
||||
|
@ -28,7 +28,7 @@ window.addEventListener("load", function () {
|
||||
"optInShown": true,
|
||||
"customShown": true
|
||||
});
|
||||
open(location).close();
|
||||
window.close();
|
||||
});
|
||||
|
||||
var custom_enabled = document.getElementById('custom-enabled');
|
||||
@ -94,4 +94,4 @@ window.addEventListener("load", function () {
|
||||
});
|
||||
update_enabled.innerText = 'NO';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -117,7 +117,7 @@ function add_options() {
|
||||
}
|
||||
|
||||
if (title && sites_custom[title]['domain']) {
|
||||
sites_custom[title]['domain'] = sites_custom[title]['domain'].replace(/(http(s)?:\/\/(www\.)?|^www\.|\/$)/g, '').toLowerCase();
|
||||
sites_custom[title]['domain'] = sites_custom[title]['domain'].replace(/(http(s)?:\/\/|\/$)/g, '').replace(/^(www|amp(html)?|m|wap)(\d)?\./, '').toLowerCase();
|
||||
|
||||
// add new site to local storage
|
||||
ext_api.storage.local.get({
|
||||
|
@ -41,7 +41,7 @@ document.getElementById("clear_cookies").addEventListener('click', function () {
|
||||
}, function (tabs) {
|
||||
if (tabs && tabs[0] && tabs[0].url && tabs[0].url.startsWith('http')) {
|
||||
let hostname = new URL(tabs[0].url).hostname;
|
||||
let cookie_domain = hostname.replace(/^(www|amp(\d|html)?|m|wap)\./, '');
|
||||
let cookie_domain = getCookiePermDomain(hostname);
|
||||
ext_api.permissions.contains({
|
||||
origins: ["*://*." + cookie_domain + "/*"]
|
||||
}, function (result) {
|
||||
@ -69,4 +69,14 @@ function closeButton() {
|
||||
window.close();
|
||||
}
|
||||
|
||||
function getCookiePermDomain(hostname) {
|
||||
let domain = hostname.replace(/^(www|amp(html)?|m|wap)(\d)?\./, '');
|
||||
let domain_split = domain.split('.');
|
||||
let num = 2;
|
||||
if (domain_split.length > 2 && domain.match(/(\w){2,4}\.(\w){2}$/))
|
||||
num = 3;
|
||||
domain = domain_split.slice(-num).join('.');
|
||||
return domain;
|
||||
}
|
||||
|
||||
document.getElementById("button-close").addEventListener('click', closeButton);
|
||||
|
Loading…
x
Reference in New Issue
Block a user