mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-10 03:21:58 +01:00
Option to clear cookies & local storage (of site)
Plus fix-update MIT Sloan Management Review (modal)
This commit is contained in:
parent
60930063c5
commit
9c721e4ef4
9 changed files with 81 additions and 14 deletions
|
@ -321,14 +321,14 @@ For example:
|
|||
_*free articles only._
|
||||
|
||||
### 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.
|
||||
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.
|
||||
|
||||
_*May not always succeed_
|
||||
|
||||
### New site requests
|
||||
You can submit a request for a new website [here](https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/issues?status=new&status=open).
|
||||
Please read the following instructions and share your results for a quicker process.
|
||||
|
|
|
@ -747,15 +747,53 @@ ext_api.webRequest.onCompleted.addListener(function (details) {
|
|||
urls: ["<all_urls>"]
|
||||
});
|
||||
|
||||
function clear_cookies() {
|
||||
ext_api.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true
|
||||
}, function (tabs) {
|
||||
if (tabs.length > 0 && tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
|
||||
ext_api.tabs.executeScript({
|
||||
file: 'clearCookies.js',
|
||||
runAt: 'document_start'
|
||||
}, function (res) {
|
||||
if (ext_api.runtime.lastError || res[0]) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
ext_api.tabs.update(tabs[0].id, {
|
||||
url: tabs[0].url
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ext_api.runtime.onMessage.addListener(function (message, sender) {
|
||||
// check storage for opt in
|
||||
ext_api.storage.sync.get("optIn", function (result) {
|
||||
// send message back to content script with value of opt in
|
||||
ext_api.tabs.sendMessage(
|
||||
sender.tab.id, {
|
||||
"optIn": (true == result.optIn)
|
||||
if (message.request === 'optin') {
|
||||
ext_api.storage.sync.get("optIn", function (result) {
|
||||
// send message back to content script with value of opt in
|
||||
ext_api.tabs.sendMessage(
|
||||
sender.tab.id, {
|
||||
"optIn": (true == result.optIn)
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
// clear cookies for domain
|
||||
if (message.domain) {
|
||||
var domainVar = message.domain.replace('www.', '');
|
||||
ext_api.cookies.getAll({
|
||||
domain: domainVar
|
||||
}, function (cookies) {
|
||||
for (let cookie of cookies) {
|
||||
var cookie_domain = cookie.domain;
|
||||
ext_api.cookies.remove({
|
||||
url: (cookie.secure ? "https://" : "http://") + cookie.domain + cookie.path,
|
||||
name: cookie.name
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// show the tab if we haven't registered the user reacting to the prompt.
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
Changelog Bypass Paywalls Clean - Firefox
|
||||
|
||||
Post-release
|
||||
Fix-update MIT Sloan Management Review (modal)
|
||||
Option to clear cookies & local storage (of site)
|
||||
|
||||
* v1.9.0.0 (2020-10-11)
|
||||
Add Slate
|
||||
|
|
22
clearCookies.js
Normal file
22
clearCookies.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
||||
|
||||
window.localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
|
||||
// send domain to background.js (to clear cookies)
|
||||
ext_api.runtime.sendMessage({
|
||||
domain: document.domain
|
||||
});
|
||||
|
||||
let msg = "Cookies (and local storage) removed from " + document.domain;
|
||||
showMessage(msg, 2000);
|
||||
|
||||
function showMessage(msg, duration) {
|
||||
var el = document.createElement("div");
|
||||
el.setAttribute("style", "position:fixed;top:40%;left:40%;z-index:99;padding:4px;font-family: Arial, sans-serif;font-size:18px;color:white;background-color:blue;");
|
||||
el.innerText = msg;
|
||||
setTimeout(function () {
|
||||
el.parentNode.removeChild(el);
|
||||
}, duration);
|
||||
document.body.appendChild(el);
|
||||
}
|
|
@ -39,7 +39,7 @@ ext_api.runtime.onMessage.addListener(function (message, sender) {
|
|||
});
|
||||
|
||||
// ask for opt-in confirmation
|
||||
ext_api.runtime.sendMessage({});
|
||||
ext_api.runtime.sendMessage({request: 'optin'});
|
||||
|
||||
// Content workarounds/domain
|
||||
|
||||
|
|
|
@ -299,7 +299,6 @@
|
|||
"*://*.jsdelivr.net/*",
|
||||
"*://*.lightboxcdn.com/*",
|
||||
"*://*.lp4.io/*",
|
||||
"*://*.netdna-ssl.com/*",
|
||||
"*://*.nyt.com/*",
|
||||
"*://*.pasedigital.cl/*",
|
||||
"*://*.pelcro.com/*",
|
||||
|
@ -319,5 +318,5 @@
|
|||
"webRequest",
|
||||
"webRequestBlocking"
|
||||
],
|
||||
"version": "1.9.0.0"
|
||||
"version": "1.9.0.1"
|
||||
}
|
|
@ -40,5 +40,5 @@
|
|||
"webRequest",
|
||||
"webRequestBlocking"
|
||||
],
|
||||
"version": "1.9.0.0"
|
||||
"version": "1.9.0.1"
|
||||
}
|
|
@ -8,7 +8,8 @@
|
|||
<br><a href="options.html" style="color:black">Options</a> |
|
||||
<a href="options_custom.html" style="color:black">Custom</a> |
|
||||
<a href="https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/src/master/README.md" style="color:black" target="_blank">BitBucket</a> |
|
||||
<button id="site_switch">on/off</button>
|
||||
<button id="site_switch" title="en/disable current site in BPC">on/off</button> |
|
||||
<button id="clear_cookies" title="clear cookies (and local storage) for current site">clear cookies</button>
|
||||
<br><a href="https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/raw/master/changelog.txt" style="color:black" target="_blank">Changelog</a>
|
||||
<span id="version_new"></span></div>
|
||||
<script src="version.js"></script>
|
||||
|
|
5
popup.js
5
popup.js
|
@ -1,4 +1,9 @@
|
|||
var ext_api = chrome || browser;
|
||||
document.getElementById("site_switch").addEventListener('click', function() {
|
||||
ext_api.extension.getBackgroundPage().site_switch();
|
||||
window.close();
|
||||
});
|
||||
document.getElementById("clear_cookies").addEventListener('click', function() {
|
||||
ext_api.extension.getBackgroundPage().clear_cookies();
|
||||
window.close();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue