Update custom sites (auto-enable in options)

This commit is contained in:
magnolia1234 2020-08-16 09:27:33 +02:00
parent e49b96a103
commit f5cbd129df
4 changed files with 47 additions and 12 deletions

View file

@ -311,22 +311,25 @@ You can submit a request for a new website [here](https://bitbucket.org/magnolia
Please read the following instructions and share your results for a quicker process.
Remember to check the [previous requests](https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/issues) before asking for a new website.
1. Visit an article on the site you want to bypass the paywall for and copy the article title.
2. Open up a new incognito window (Ctrl+Shift+N) and paste the article title into Google.
2. Open up a new incognito window (Ctrl+Shift+P) and paste the article title into Google.
3. Click on the same article from the Google search results page. Or you can:
4. Disable javascript on the website by clicking the button right icon </> on the uBlock panel.
4. Disable javascript on the website by clicking the button right icon </> on the uBlock Origin panel.
5. Refresh the page.
### Add custom site
Add your own custom site (also for testing).
Check 'Options'-link in popup-menu and go to custom sites.
By default sites' cookies are removed after page loads (to bypass article limit).
Make sure the (new) site is checked under Options.
By default sites' cookies/local storage are removed after page loads (to bypass article limit).
Also you can enable Googlebot user-agent or disable Javascript for (sub)domain(s)/external sources.
### Troubleshooting
* This add-on works best alongside [uBlock Origin](https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/).
* This add-on works best alongside the adblocker [uBlock Origin](https://addons.mozilla.org/en-US/firefox/addon/ublock-origin/).
* If a site doesn't work try turning off uBlock and refreshing.
* If you live in the EU, also consider installing the extension [I don't care about cookies](https://addons.mozilla.org/en-US/firefox/addon/i-dont-care-about-cookies) in order to remove cookie warnings.
* Make sure the (new) site is checked under Options.
* You will be logged out for most of the sites you have checked.
* If you live in the EU, also consider installing the extension [I don't care about cookies](https://addons.mozilla.org/en-US/firefox/addon/i-dont-care-about-cookies) in order to remove cookie warnings.
### Changelog-releases
* Visit the [changelog page](https://bitbucket.org/magnolia1234/bypass-paywalls-firefox-clean/src/master/changelog.txt).

View file

@ -304,6 +304,28 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
}
if (key === 'sites_custom') {
var sites_custom = storageChange.newValue;
var sites_custom_old = storageChange.oldValue;
// add/remove custom sites in options
var sites_custom_added = Object.keys(sites_custom).filter(x => !Object.keys(sites_custom_old).includes(x) && !defaultSites.hasOwnProperty(x));
var sites_custom_removed = Object.keys(sites_custom_old).filter(x => !Object.keys(sites_custom).includes(x) && !defaultSites.hasOwnProperty(x));
chrome.storage.sync.get({
sites: {}
}, function (items) {
var sites = items.sites;
for (var key of sites_custom_added)
sites[key] = sites_custom[key].domain;
for (var key of sites_custom_removed)
delete sites[key];
chrome.storage.sync.set({
sites: sites
}, function () {
true;
});
});
use_google_bot = use_google_bot_default.slice();
block_js_custom = [];
block_js_custom_ext = [];
@ -323,6 +345,18 @@ ext_api.storage.onChanged.addListener(function (changes, namespace) {
// reset disableJavascriptOnListedSites eventListener
ext_api.webRequest.onBeforeRequest.removeListener(disableJavascriptOnListedSites);
ext_api.webRequest.handlerBehaviorChanged();
// Refresh the current tab
ext_api.tabs.query({
active: true,
currentWindow: true
}, function (tabs) {
if (tabs[0].url && tabs[0].url.indexOf("http") !== -1) {
ext_api.tabs.update(tabs[0].id, {
url: tabs[0].url
});
}
});
}
}
});

View file

@ -16,8 +16,8 @@
<body>
<h2>Custom Sites</h2>
<div style="width:90%;">
To add new site, enter a unique title/domain (without www.) and select options for googlebot/block javascript (block on (sub)domain of site and/or external domains).
Then enable your new site in <a href="options.html" style="color:black">options</a> (cookies will be removed by default).
To add new site, enter a unique title/domain (without www.) and select options for Googlebot/block Javascript (block on (sub)domain(s) of site and/or external domains).<br>
Custom sites are enabled automatically in <a href="options.html" style="color:black">options</a> (cookies will be removed by default).
<br/><br/>
</div>
<div id='add_site'></div>
@ -29,8 +29,7 @@
<div style="clear:both;"></div>
<div>
<h3>List of custom sites</h3>
Disable deleted sites in <a href="options.html" style="color:black">options</a>.
<br/><br/>
<br/>
</div>
<div id='custom_sites'></div>
<br/>

View file

@ -124,7 +124,7 @@ function add_options() {
}, function () {
// Update status to let user know new custom site was added.
var status_add = document.getElementById('status_add');
status_add.textContent = 'Site added. Also enable site in options (save).';
status_add.textContent = 'Site added.';
setTimeout(function () {
//status.textContent = '';
renderOptions();
@ -151,7 +151,7 @@ function delete_options() {
}, function () {
// Update status to let user know custom site was deleted.
var status_delete = document.getElementById('status_delete');
status_delete.textContent = 'Site deleted. Also disable site in options (save).';
status_delete.textContent = 'Site deleted.';
setTimeout(function () {
//status.textContent = '';
renderOptions();
@ -221,7 +221,6 @@ function renderOptions() {
selectEl.add(optionEl);
}
labelEl.appendChild(selectEl);
//labelEl.appendChild(document.createTextNode(''));
custom_sitesEl.appendChild(labelEl);
});