Update popup (permission to clear cookies)

merge-requests/3/head
magnolia1234 3 years ago
parent 902be2ffa6
commit ea260f62fc

@ -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

@ -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)

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

@ -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) {

@ -1,38 +1,60 @@
var ext_api = (typeof browser === 'object') ? browser : chrome; var ext_api = (typeof browser === 'object') ? browser : chrome;
function popup_show_toggle(domain, enabled) { function popup_show_toggle(domain, enabled) {
if (domain) { if (domain) {
var site_switch_span = document.getElementById('site_switch_span'); var site_switch_span = document.getElementById('site_switch_span');
let labelEl = document.createElement('label'); let labelEl = document.createElement('label');
labelEl.setAttribute('class', 'switch'); labelEl.setAttribute('class', 'switch');
let inputEl = document.createElement('input'); let inputEl = document.createElement('input');
inputEl.setAttribute('id', 'site_switch'); inputEl.setAttribute('id', 'site_switch');
inputEl.setAttribute('type', 'checkbox'); inputEl.setAttribute('type', 'checkbox');
if (enabled) if (enabled)
inputEl.setAttribute('checked', true); inputEl.setAttribute('checked', true);
labelEl.appendChild(inputEl); labelEl.appendChild(inputEl);
let spanEl = document.createElement('span'); let spanEl = document.createElement('span');
spanEl.setAttribute('class', 'slider round'); spanEl.setAttribute('class', 'slider round');
spanEl.setAttribute('title', 'en/disable current site in BPC'); spanEl.setAttribute('title', 'en/disable current site in BPC');
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({
//open(location).close(); request: 'site_switch'
}); });
} //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() {

Loading…
Cancel
Save