Update popup (permission to clear cookies)

This commit is contained in:
magnolia1234 2021-12-30 20:36:01 +01:00
parent 902be2ffa6
commit ea260f62fc
5 changed files with 54 additions and 34 deletions

View File

@ -659,11 +659,7 @@ _* free articles only._
### Sites with limited number of free articles ### Sites with limited number of free articles
The free article limit can normally be bypassed by removing cookies for the site. The free article limit can normally be bypassed by removing cookies for the site.
Click on the BPC-icon and then 'clear cookies'-button in the popup. Click on the BPC-icon and then 'clear cookies'-button in the popup (for unsupported sites grant permission for domain).
For user with the limited permissions BPC-version this will only work for supported sites; for other sites use:
1. Install the add-on [Cookie Remover](https://addons.mozilla.org/en-US/firefox/addon/cookie-remover).
2. When coming across a paywall click the cookie icon to remove the cookies then refresh the page.
If removing the cookies works you can also add the site as a custom site. If removing the cookies works you can also add the site as a custom site.
### New site requests ### New site requests

View File

@ -5,6 +5,7 @@ Post-release
Add Capital Gazette (local USA) Add Capital Gazette (local USA)
Add Il Foglio (Italy) Add Il Foglio (Italy)
Fix group Tribune Publishing Company (js) Fix group Tribune Publishing Company (js)
Update popup (permission to clear cookies)
* v2.4.9.0 (2021-12-26) * v2.4.9.0 (2021-12-26)
Add El Espectador (Colombia) Add El Espectador (Colombia)

View File

@ -600,5 +600,5 @@
"*://*.wsj.net/*", "*://*.wsj.net/*",
"*://*.zephr.com/*" "*://*.zephr.com/*"
], ],
"version": "2.4.9.2" "version": "2.4.9.3"
} }

View File

@ -3,12 +3,13 @@ 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)\./, '');
// 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: document.domain domain: cookie_domain
}); });
let msg = "Cookies (and local storage) removed from " + document.domain; var msg = "Cookies (and local storage) removed from " + cookie_domain;
showMessage(msg, 2000); showMessage(msg, 2000);
function showMessage(msg, duration) { function showMessage(msg, duration) {

View File

@ -17,22 +17,44 @@ function popup_show_toggle(domain, enabled) {
labelEl.appendChild(spanEl); labelEl.appendChild(spanEl);
site_switch_span.appendChild(labelEl); site_switch_span.appendChild(labelEl);
document.getElementById("site_switch").addEventListener('click', function () { document.getElementById("site_switch").addEventListener('click', function () {
ext_api.runtime.sendMessage({request: 'site_switch'}); ext_api.runtime.sendMessage({
request: 'site_switch'
});
//open(location).close(); //open(location).close();
}); });
} }
}; };
ext_api.runtime.sendMessage({request: 'popup_show_toggle'}); ext_api.runtime.sendMessage({
request: 'popup_show_toggle'
});
ext_api.runtime.onMessage.addListener(function (message, sender) { ext_api.runtime.onMessage.addListener(function (message, sender) {
if (message.msg === 'popup_show_toggle' && message.data) { if (message.msg === 'popup_show_toggle' && message.data) {
popup_show_toggle(message.data.domain, message.data.enabled) popup_show_toggle(message.data.domain, message.data.enabled)
} }
}); });
var cookie_domain;
ext_api.tabs.query({
active: true,
currentWindow: true
}, function (tabs) {
if (tabs && tabs[0] && tabs[0].url && tabs[0].url.startsWith('http')) {
let hostname = new URL(tabs[0].url).hostname;
cookie_domain = hostname.replace(/^(www|amp(\d|html)?|m|wap)\./, '');
}
});
document.getElementById("clear_cookies").addEventListener('click', function () { document.getElementById("clear_cookies").addEventListener('click', function () {
ext_api.runtime.sendMessage({request: 'clear_cookies'}); ext_api.permissions.request({
//open(location).close(); origins: ["*://*." + cookie_domain + "/*"]
}, function (granted) {
if (granted) {
ext_api.runtime.sendMessage({
request: 'clear_cookies'
});
}
});
}); });
function closeButton() { function closeButton() {