Update popup (domain to clear cookies)
parent
352e2852e1
commit
e37fadb501
|
@ -214,8 +214,13 @@ function set_rules(sites, sites_updated, sites_custom) {
|
||||||
if (rule.hasOwnProperty('block_regex')) {
|
if (rule.hasOwnProperty('block_regex')) {
|
||||||
if (rule.block_regex instanceof RegExp)
|
if (rule.block_regex instanceof RegExp)
|
||||||
blockedRegexes[domain] = rule.block_regex;
|
blockedRegexes[domain] = rule.block_regex;
|
||||||
else
|
else {
|
||||||
blockedRegexes[domain] = new RegExp(rule.block_regex.replace('{domain}', domain.replace(/\./g, '\\.').replace(/(^\/|\/$)/g, '')));
|
try {
|
||||||
|
blockedRegexes[domain] = new RegExp(rule.block_regex.replace('{domain}', domain.replace(/\./g, '\\.').replace(/(^\/|\/$)/g, '')));
|
||||||
|
} catch (e) {
|
||||||
|
false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (rule.useragent) {
|
if (rule.useragent) {
|
||||||
switch (rule.useragent) {
|
switch (rule.useragent) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ Changelog Bypass Paywalls Clean - Chrome
|
||||||
Post-release
|
Post-release
|
||||||
Add Mainichi Shimbun (Japan)
|
Add Mainichi Shimbun (Japan)
|
||||||
Fix Bloomberg (quotes)
|
Fix Bloomberg (quotes)
|
||||||
|
Update popup (domain to clear cookies)
|
||||||
|
|
||||||
* v2.5.1.0 (2022-01-09)
|
* v2.5.1.0 (2022-01-09)
|
||||||
Add group Hearst Communications (local USA)
|
Add group Hearst Communications (local USA)
|
||||||
|
|
|
@ -3,12 +3,26 @@ var ext_api = (typeof browser === 'object') ? browser : chrome;
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
sessionStorage.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)
|
// send domain to background.js (to clear cookies)
|
||||||
ext_api.runtime.sendMessage({
|
ext_api.runtime.sendMessage({
|
||||||
domain: cookie_domain
|
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;
|
var msg = "Cookies (and local storage) removed from " + cookie_domain;
|
||||||
showMessage(msg, 2000);
|
showMessage(msg, 2000);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ window.addEventListener("load", function () {
|
||||||
"optInShown": true,
|
"optInShown": true,
|
||||||
"customShown": true
|
"customShown": true
|
||||||
});
|
});
|
||||||
open(location).close();
|
window.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
var custom_enabled = document.getElementById('custom-enabled');
|
var custom_enabled = document.getElementById('custom-enabled');
|
||||||
|
@ -94,4 +94,4 @@ window.addEventListener("load", function () {
|
||||||
});
|
});
|
||||||
update_enabled.innerText = 'NO';
|
update_enabled.innerText = 'NO';
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -117,7 +117,7 @@ function add_options() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (title && sites_custom[title]['domain']) {
|
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
|
// add new site to local storage
|
||||||
ext_api.storage.local.get({
|
ext_api.storage.local.get({
|
||||||
|
|
|
@ -41,7 +41,7 @@ document.getElementById("clear_cookies").addEventListener('click', function () {
|
||||||
}, function (tabs) {
|
}, function (tabs) {
|
||||||
if (tabs && tabs[0] && tabs[0].url && tabs[0].url.startsWith('http')) {
|
if (tabs && tabs[0] && tabs[0].url && tabs[0].url.startsWith('http')) {
|
||||||
let hostname = new URL(tabs[0].url).hostname;
|
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({
|
ext_api.permissions.contains({
|
||||||
origins: ["*://*." + cookie_domain + "/*"]
|
origins: ["*://*." + cookie_domain + "/*"]
|
||||||
}, function (result) {
|
}, function (result) {
|
||||||
|
@ -69,4 +69,14 @@ function closeButton() {
|
||||||
window.close();
|
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);
|
document.getElementById("button-close").addEventListener('click', closeButton);
|
||||||
|
|
Loading…
Reference in New Issue