Upgrade to the latest version.
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
||||
|
||||
try {
|
||||
window.localStorage.clear();
|
||||
sessionStorage.clear();
|
||||
window.localStorage.clear();
|
||||
window.sessionStorage.clear();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
@@ -23,11 +23,11 @@ function getCookieDomain(hostname) {
|
||||
let parts = hostname.split('.');
|
||||
let str = '_gd' + (new Date()).getTime();
|
||||
try {
|
||||
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 + ";";
|
||||
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 + ";";
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
@@ -38,11 +38,11 @@ var msg = "Cookies (and local storage) removed from " + cookie_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 || document.head || document.documentElement).appendChild(el);
|
||||
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 || document.head || document.documentElement).appendChild(el);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Bypass Paywalls Clean (setCookie, custom sites & check update opt-in)</title>
|
||||
<title>Bypass Paywalls Clean (opt-in)</title>
|
||||
<link rel="stylesheet" href="../options_all.css"/>
|
||||
<link rel="stylesheet" href="opt-in.css"/>
|
||||
<script src="opt-in.js"></script>
|
||||
@@ -12,7 +12,38 @@
|
||||
|
||||
<body>
|
||||
<div>
|
||||
<p><strong>Bypass Paywalls Clean<br> - setCookie, custom sites & check update opt-in</strong></p>
|
||||
<p><strong>Bypass Paywalls Clean<br>Opt-in options for additonal functionality/consent.</strong></p>
|
||||
</div>
|
||||
</div>
|
||||
<div id="custom-prompt">
|
||||
<p><strong>custom sites opt-in</strong></p>
|
||||
<p>If you want to enable <a href="../options_custom.html">custom sites</a> (for new sites) and also have the option to remove cookies/block general paywall-scripts of 'unlisted' sites:</br>
|
||||
<p>custom sites enabled: <span id="custom-enabled"></span></p>
|
||||
<div id="custom-container">
|
||||
<button id="custom-enable">Enable</button>
|
||||
<button id="custom-disable">Disable</button>
|
||||
<span id="mv3-remove-perm-msg" style="color: red;">
|
||||
</div>
|
||||
</div>
|
||||
<div id="update-prompt">
|
||||
<p><strong>check update opt-in</strong></p>
|
||||
<p>Check for update of version (on startup and when opening options):</br>
|
||||
<p>check update enabled: <span id="update-enabled"></span></p>
|
||||
<div id="update-container">
|
||||
<button id="update-enable">Enable</button>
|
||||
<button id="update-disable">Disable</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="fetch-prompt">
|
||||
<p><strong>fetch consent opt-in</strong></p>
|
||||
For some sites (see options) the full article content is fetched from an external site (like archive.is).</br>
|
||||
This requires a 'data transmission' (no data collection by add-on) of the article-url to this external site.</br>
|
||||
If you disable 'fetch consent' (default setting) this add-on will not work for these sites.</br>
|
||||
</p>
|
||||
<p>Fetch enabled: <span id="fetch-enabled"></span></p>
|
||||
<div id="fetch-container">
|
||||
<button id="fetch-enable">Enable</button>
|
||||
<button id="fetch-disable">Disable</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="opt-in-prompt">
|
||||
@@ -23,34 +54,6 @@
|
||||
<div id="optin-container">
|
||||
<button id="optin-enable">Enable</button>
|
||||
<button id="optin-disable">Disable</button>
|
||||
</div>
|
||||
<div id="custom-prompt">
|
||||
<p><strong>custom sites opt-in</strong></p>
|
||||
<p>If you want to enable custom sites and also have the option to remove cookies/block general paywall-scripts of 'unlisted' sites:</br>
|
||||
<p>custom sites enabled: <span id="custom-enabled"></span></p>
|
||||
<div id="custom-container">
|
||||
<button id="custom-enable">Enable</button>
|
||||
<button id="custom-disable">Disable</button>
|
||||
</div>
|
||||
<p>You can also just request permissions for the <a href="../options_custom.html">custom sites</a> you added yourself.</p>
|
||||
</div>
|
||||
<div id="update-prompt">
|
||||
<p><strong>check update opt-in</strong></p>
|
||||
<p>Check for update of version (on startup and when opening options):</br>
|
||||
<p>check update enabled: <span id="update-enabled"></span></p>
|
||||
<div id="update-container">
|
||||
<button id="update-enable">Enable</button>
|
||||
<button id="update-disable">Disable</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="counter-prompt">
|
||||
<p><strong>daily users counter opt-in</strong></p>
|
||||
<p>Very basic daily users counter (by counting the download of an empty json-file (no personal information is shared)):</br>
|
||||
<p>daily users counter enabled: <span id="counter-enabled"></span></p>
|
||||
<div id="custom-container">
|
||||
<button id="counter-enable">Enable</button>
|
||||
<button id="counter-disable">Disable</button>
|
||||
</div>
|
||||
</div>
|
||||
<p>
|
||||
<div style='float:left;padding-bottom:50px'>
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
||||
var url_loc = (typeof browser === 'object') ? 'firefox' : 'chrome';
|
||||
var manifestData = ext_api.runtime.getManifest();
|
||||
var ext_manifest_version = manifestData.manifest_version;
|
||||
var navigator_ua = navigator.userAgent;
|
||||
var navigator_ua_mobile = navigator_ua.toLowerCase().includes('mobile');
|
||||
var yandex_browser = navigator_ua_mobile && (url_loc === 'chrome') && navigator_ua.toLowerCase().includes('yabrowser');
|
||||
var custom_switch = ((manifestData.optional_permissions && manifestData.optional_permissions.length) || (manifestData.optional_host_permissions && manifestData.optional_host_permissions.length)) && !(navigator_ua_mobile && (url_loc === 'chrome') && !yandex_browser);
|
||||
var chrome_android_browser = navigator_ua_mobile && (url_loc === 'chrome');
|
||||
var custom_switch = ((manifestData.optional_permissions && manifestData.optional_permissions.length) || (manifestData.optional_host_permissions && manifestData.optional_host_permissions.length));
|
||||
|
||||
window.addEventListener("load", function () {
|
||||
document.getElementById("button-close").addEventListener("click", function () {
|
||||
ext_api.storage.local.set({
|
||||
"optInShown": true,
|
||||
"customShown": true
|
||||
"customShown": true,
|
||||
"fetchShown": true
|
||||
});
|
||||
window.close();
|
||||
});
|
||||
@@ -19,6 +21,7 @@ window.addEventListener("load", function () {
|
||||
ext_api.storage.local.get("optIn", function (result) {
|
||||
opt_in_enabled.innerText = result.optIn ? 'YES' : 'NO';
|
||||
});
|
||||
var mv3_remove_perm_msg = document.getElementById('mv3-remove-perm-msg');
|
||||
|
||||
document.getElementById("optin-enable").addEventListener("click", function () {
|
||||
ext_api.storage.local.set({
|
||||
@@ -47,6 +50,13 @@ window.addEventListener("load", function () {
|
||||
}
|
||||
});
|
||||
|
||||
var custom_prompt = document.getElementById('custom-prompt');
|
||||
if (chrome_android_browser) {
|
||||
var android_span = document.createElement('span');
|
||||
android_span.innerText = '* to enable the custom sites opt-in on Android you may need to use the android-custom crx-release.';
|
||||
custom_prompt.appendChild(android_span);
|
||||
}
|
||||
|
||||
if (custom_switch) {
|
||||
|
||||
document.querySelector('#custom-enable').addEventListener('click', function (event) {
|
||||
@@ -58,6 +68,8 @@ window.addEventListener("load", function () {
|
||||
ext_api.storage.local.set({
|
||||
"customOptIn": true
|
||||
});
|
||||
if (ext_manifest_version === 3)
|
||||
mv3_remove_perm_msg.innerText = '';
|
||||
} else {
|
||||
custom_enabled.innerText = 'NO';
|
||||
}
|
||||
@@ -69,13 +81,17 @@ window.addEventListener("load", function () {
|
||||
|
||||
document.querySelector('#custom-disable').addEventListener('click', function (event) {
|
||||
ext_api.permissions.remove({
|
||||
origins: ["*://*/*", "<all_urls>"]
|
||||
origins: ["*://*/*"]
|
||||
}, function (removed) {
|
||||
if (removed) {
|
||||
custom_enabled.innerText = 'NO';
|
||||
ext_api.storage.local.set({
|
||||
"customOptIn": false
|
||||
});
|
||||
if (ext_manifest_version === 3) {
|
||||
mv3_remove_perm_msg.innerText = 'Extension will be reloaded to apply changes in optional host permissions.';
|
||||
ext_api.runtime.reload();
|
||||
}
|
||||
}
|
||||
ext_api.storage.local.set({
|
||||
"customShown": true
|
||||
@@ -104,22 +120,33 @@ window.addEventListener("load", function () {
|
||||
update_enabled.innerText = 'NO';
|
||||
});
|
||||
|
||||
var counter_enabled = document.getElementById('counter-enabled');
|
||||
ext_api.storage.local.get({counter: true}, function (result) {
|
||||
counter_enabled.innerText = result.counter ? 'YES' : 'NO';
|
||||
if (typeof browser === 'object') { // fetch consent (Firefox only)
|
||||
|
||||
var fetch_enabled = document.getElementById('fetch-enabled');
|
||||
ext_api.storage.local.get("optInFetch", function (result) {
|
||||
fetch_enabled.innerText = result.optInFetch ? 'YES' : 'NO';
|
||||
});
|
||||
|
||||
document.getElementById("counter-enable").addEventListener("click", function () {
|
||||
document.getElementById("fetch-enable").addEventListener("click", function () {
|
||||
ext_api.storage.local.set({
|
||||
"counter": true
|
||||
"optInFetch": true,
|
||||
"fetchShown": true
|
||||
});
|
||||
counter_enabled.innerText = 'YES';
|
||||
fetch_enabled.innerText = 'YES';
|
||||
});
|
||||
|
||||
document.getElementById("counter-disable").addEventListener("click", function () {
|
||||
document.getElementById("fetch-disable").addEventListener("click", function () {
|
||||
ext_api.storage.local.set({
|
||||
"counter": false
|
||||
"optInFetch": false,
|
||||
"fetchShown": true
|
||||
});
|
||||
counter_enabled.innerText = 'NO';
|
||||
fetch_enabled.innerText = 'NO';
|
||||
});
|
||||
|
||||
} else {
|
||||
let fetch_prompt = document.querySelector('div#fetch-prompt');
|
||||
if (fetch_prompt)
|
||||
fetch_prompt.style = 'display: none';
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="top">Options | <small><span id="version"></span><br><span id="version_new"></span></small></h1>
|
||||
<br><a href="/changelog.txt" target="_blank">Changelog</a>
|
||||
Changelog <a href="/changelog.txt" target="_blank">local</a> or <a href="https://gitflic.ru/project/magnolia1234/bypass-paywalls-chrome-clean/blob/raw?file=changelog.txt" target="_blank">online</a>
|
||||
| Help <a href="/Readme.html" target="_blank">local</a> or <a href="https://gitflic.ru/project/magnolia1234/bypass-paywalls-chrome-clean" target="_blank">online</a>
|
||||
<div style="width:90%;">
|
||||
<br>Some selected sites will have their cookies cleared; uncheck the sites (or add to excluded sites) for which you have an account.<br>
|
||||
If you also want to block general paywall-scripts for unlisted sites you have to opt-in to custom sites (host permission for access to all sites is needed).
|
||||
@@ -27,6 +28,7 @@
|
||||
</div>
|
||||
<div style="clear:both;"></div>
|
||||
<strong style="color:red;"><div id="perm-custom"></div></strong>
|
||||
<strong style="color:red;"><div id="nofix"></div></strong>
|
||||
<div style="clear:both;"></div>
|
||||
<br>
|
||||
<div id="status_top"></div>
|
||||
|
||||
@@ -56,6 +56,7 @@ function renderOptions() {
|
||||
perm_custom.innerText = '';
|
||||
} else {
|
||||
perm_custom.textContent = ">> check host (domain) permissions for custom/updated sites";
|
||||
perm_custom.style.margin = '10px';
|
||||
}
|
||||
});
|
||||
|
||||
@@ -69,18 +70,24 @@ function renderOptions() {
|
||||
},
|
||||
"default": {
|
||||
sites: defaultSites,
|
||||
title: '* Default settings',
|
||||
default_sites: true
|
||||
},
|
||||
"custom": {
|
||||
sites: sites_custom,
|
||||
title: '* Custom (new) sites',
|
||||
default_sites: false
|
||||
}
|
||||
};
|
||||
for (let site_type in site_types) {
|
||||
labelEl = document.createElement('label');
|
||||
labelEl.setAttribute('style', ' font-weight: bold;');
|
||||
if (site_types[site_type].title)
|
||||
if (site_types[site_type].title) {
|
||||
labelEl.appendChild(document.createElement('hr'));
|
||||
labelEl.appendChild(document.createTextNode(site_types[site_type].title));
|
||||
if (site_type !== 'updated' && Object.keys(site_types[site_type].sites).length)
|
||||
labelEl.appendChild(document.createTextNode(' - #' + Object.keys(site_types[site_type].sites).length));
|
||||
}
|
||||
sitesEl.appendChild(labelEl);
|
||||
let sites_arr = site_types[site_type].sites;
|
||||
for (let key in sites_arr) {
|
||||
@@ -152,6 +159,12 @@ function handleSearch() {
|
||||
else
|
||||
item.style.display = 'none';
|
||||
}
|
||||
var nofix = document.getElementById('nofix');
|
||||
if (nofix_sites.includes(search)) {
|
||||
nofix.innerText = 'No (proper) fix for domain ' + search + ', but it may still be part of (imported) custom sites.';
|
||||
nofix.style.margin = '10px';
|
||||
} else
|
||||
nofix.innerText = '';
|
||||
});
|
||||
|
||||
let selectButtons = document.querySelectorAll('#select-all, #select-none');
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<h2>Custom Sites</h2>
|
||||
<div id="custom-update"></div>
|
||||
<div style="width:90%;">
|
||||
To add a new site, enter an unique title/domain (without www.).<br>
|
||||
Select options below (<a href="/README.html#add-custom-site" target="_blank">see help</a>); for examples import from online.<br>
|
||||
@@ -58,8 +59,9 @@
|
||||
<button id="sort">Sort</button>
|
||||
<button id="export">Export</button>
|
||||
<button id="import">Import file</button>
|
||||
<button id="import_local">Import from local</button>
|
||||
<button id="import_online">Import from online</button>
|
||||
<input type="file" id="importInput" accept=".txt" style="display:none"/>
|
||||
<input type="file" id="importInput" accept=".txt, .json" style="display:none"/>
|
||||
<button><a href="options.html" style="text-decoration:none;color:inherit">Options</a></button>
|
||||
</span>
|
||||
|
||||
|
||||
@@ -3,13 +3,12 @@ var url_loc = (typeof browser === 'object') ? 'firefox' : 'chrome';
|
||||
var manifestData = ext_api.runtime.getManifest();
|
||||
var navigator_ua = navigator.userAgent;
|
||||
var navigator_ua_mobile = navigator_ua.toLowerCase().includes('mobile');
|
||||
var yandex_browser = navigator_ua_mobile && (url_loc === 'chrome') && navigator_ua.toLowerCase().includes('yabrowser');
|
||||
var custom_switch = ((manifestData.optional_permissions && manifestData.optional_permissions.length) || (manifestData.optional_host_permissions && manifestData.optional_host_permissions.length)) && !(navigator_ua_mobile && (url_loc === 'chrome') && !yandex_browser);
|
||||
var custom_switch = ((manifestData.optional_permissions && manifestData.optional_permissions.length) || (manifestData.optional_host_permissions && manifestData.optional_host_permissions.length));
|
||||
|
||||
var useragent_options = ['', 'googlebot', 'bingbot', 'facebookbot'];
|
||||
var referer_options = ['', 'facebook', 'google', 'twitter'];
|
||||
var random_ip_options = ['', 'all', 'eu'];
|
||||
var add_ext_link_type_options = ['', 'archive.is', '1ft.io', 'google_webcache', 'google_search_tool'];
|
||||
var add_ext_link_type_options = ['', 'archive.is', 'google_search_tool'];
|
||||
|
||||
function capitalize(str) {
|
||||
return (typeof str === 'string') ? str.charAt(0).toUpperCase() + str.slice(1) : '';
|
||||
@@ -103,7 +102,7 @@ function import_json(result) {
|
||||
sites_custom[site] = sites_custom_new[site];
|
||||
}
|
||||
sites_custom = filterObject(sites_custom, function (val, key) {
|
||||
return !(customSitesExt_remove.includes(val.domain) || (val.add_ext_link && !val.add_ext_link_type))
|
||||
return val.domain && !(customSitesExt_remove.includes(val.domain) || (val.add_ext_link && !val.add_ext_link_type))
|
||||
});
|
||||
ext_api.storage.local.set({
|
||||
sites_custom: sortJson(sites_custom)
|
||||
@@ -120,9 +119,15 @@ function import_json(result) {
|
||||
});
|
||||
}
|
||||
|
||||
// Import custom sites from online
|
||||
function import_online_options(e) {
|
||||
let url = 'https://bitbucket.org/bpc-updates/bpc_updates/downloads/sites_custom.json';
|
||||
function randomInt(max) {
|
||||
return Math.floor(Math.random() * Math.floor(max));
|
||||
}
|
||||
|
||||
// Import custom sites from local/online
|
||||
function import_url_options(e, online) {
|
||||
let url = '/custom/sites_custom.json';
|
||||
if (online)
|
||||
url = 'https://gitflic.ru/project/magnolia1234/bpc_updates/blob/raw?file=sites_custom.json';
|
||||
try {
|
||||
fetch(url)
|
||||
.then(response => {
|
||||
@@ -272,13 +277,14 @@ function edit_options() {
|
||||
document.querySelector('textarea[data-key="group"]').value = edit_site.group || '';
|
||||
document.querySelector('input[data-key="allow_cookies"]').checked = (edit_site.allow_cookies > 0);
|
||||
document.querySelector('input[data-key="remove_cookies"]').checked = (edit_site.remove_cookies > 0);
|
||||
document.querySelector('select[data-key="useragent"]').selectedIndex = (edit_site.googlebot > 0) ? 1 : useragent_options.indexOf(edit_site.useragent);
|
||||
document.querySelector('input[data-key="cs_clear_lclstrg"]').checked = (edit_site.cs_clear_lclstrg > 0);
|
||||
document.querySelector('select[data-key="useragent"]').selectedIndex = useragent_options.indexOf(edit_site.useragent);
|
||||
document.querySelector('textarea[data-key="useragent_custom"]').value = edit_site.useragent_custom || '';
|
||||
document.querySelector('select[data-key="referer"]').selectedIndex = referer_options.indexOf(edit_site.referer);
|
||||
document.querySelector('textarea[data-key="referer_custom"]').value = edit_site.referer_custom || '';
|
||||
document.querySelector('select[data-key="random_ip"]').selectedIndex = random_ip_options.indexOf(edit_site.random_ip);
|
||||
document.querySelector('input[data-key="block_js"]').checked = (edit_site.block_js > 0 || edit_site.block_javascript > 0);
|
||||
document.querySelector('input[data-key="block_js_ext"]').checked = (edit_site.block_js_ext > 0 || edit_site.block_javascript_ext > 0);
|
||||
document.querySelector('input[data-key="block_js"]').checked = (edit_site.block_js > 0);
|
||||
document.querySelector('input[data-key="block_js_ext"]').checked = (edit_site.block_js_ext > 0);
|
||||
document.querySelector('input[data-key="block_js_inline"]').value = edit_site.block_js_inline || '';
|
||||
document.querySelector('input[data-key="block_regex"]').value = edit_site.block_regex || '';
|
||||
document.querySelector('input[data-key="block_regex_ignore_default"]').checked = (edit_site.block_regex_ignore_default > 0 || edit_site.block_regex_ignore_default > 0);
|
||||
@@ -287,9 +293,9 @@ function edit_options() {
|
||||
document.querySelector('input[data-key="amp_redirect"]').value = edit_site.amp_redirect || '';
|
||||
document.querySelector('input[data-key="ld_json"]').value = edit_site.ld_json || '';
|
||||
document.querySelector('input[data-key="ld_json_next"]').value = edit_site.ld_json_next || '';
|
||||
document.querySelector('input[data-key="ld_json_source"]').value = edit_site.ld_json_source || '';
|
||||
document.querySelector('input[data-key="ld_json_url"]').value = edit_site.ld_json_url || '';
|
||||
document.querySelector('input[data-key="ld_archive_is"]').value = edit_site.ld_archive_is || '';
|
||||
document.querySelector('input[data-key="ld_google_webcache"]').value = edit_site.ld_google_webcache || '';
|
||||
document.querySelector('input[data-key="add_ext_link"]').value = edit_site.add_ext_link || '';
|
||||
document.querySelector('select[data-key="add_ext_link_type"]').selectedIndex = add_ext_link_type_options.indexOf(edit_site.add_ext_link_type);
|
||||
document.querySelector('textarea[data-key="cs_code"]').value = edit_site.cs_code || '';
|
||||
@@ -327,7 +333,8 @@ var perm_origins;
|
||||
function renderOptions() {
|
||||
ext_api.storage.local.get({
|
||||
sites_custom: {},
|
||||
sites_updated: {}
|
||||
sites_updated: {},
|
||||
sites_custom_upd_version: ''
|
||||
}, function (items) {
|
||||
var sites_custom = sortJson(items.sites_custom);
|
||||
var sites_custom_domains_new = Object.values(sites_custom).filter(x => x.domain && !defaultSites_domains.includes(x.domain)).map(x => x.group ? x.group.split(',').filter(x => x).map(x => x.trim()) : x.domain).flat();
|
||||
@@ -357,6 +364,7 @@ function renderOptions() {
|
||||
'group': 0,
|
||||
'allow_cookies': 1,
|
||||
'remove_cookies': 1,
|
||||
'cs_clear_lclstrg (clear localStorage)': 1,
|
||||
'useragent': 0,
|
||||
'useragent_custom': 0,
|
||||
'referer': 0,
|
||||
@@ -372,9 +380,9 @@ function renderOptions() {
|
||||
'amp_redirect': 0,
|
||||
'ld_json': 0,
|
||||
'ld_json_next': 0,
|
||||
'ld_json_source': 0,
|
||||
'ld_json_url': 0,
|
||||
'ld_archive_is': 0,
|
||||
'ld_google_webcache': 0,
|
||||
'add_ext_link': 0,
|
||||
'add_ext_link_type': 0,
|
||||
'cs_code': 0,
|
||||
@@ -402,11 +410,11 @@ function renderOptions() {
|
||||
} else {
|
||||
if (!['cs_code', 'group', 'referer_custom', 'useragent_custom'].includes(key)) {
|
||||
inputEl = document.createElement('input');
|
||||
inputEl.size = 25;
|
||||
inputEl.size = 35;
|
||||
} else {
|
||||
inputEl = document.createElement('textarea');
|
||||
inputEl.rows = 5;
|
||||
inputEl.cols = 25;
|
||||
inputEl.cols = 35;
|
||||
}
|
||||
let placeholders = {
|
||||
title: 'Example',
|
||||
@@ -415,12 +423,12 @@ function renderOptions() {
|
||||
block_js_inline: '\\.example\\.com\\/article\\/',
|
||||
block_regex: '\\.example\\.com\\/js\\/',
|
||||
block_host_perm_add: 'example1.com,example2.com',
|
||||
amp_redirect: 'div.paywall',
|
||||
amp_redirect: 'div.paywall|amp_url',
|
||||
ld_json: 'div.paywall|div.article',
|
||||
ld_json_next: 'div.paywall|div.article',
|
||||
ld_json_source: 'div.paywall|div.article|filter|json_key',
|
||||
ld_json_url: 'div.paywall|div.article',
|
||||
ld_archive_is: 'div.paywall|div.art|div.art_src|div.art_link',
|
||||
ld_google_webcache: 'div.paywall|div.article',
|
||||
add_ext_link: 'div.paywall|div.article',
|
||||
cs_code: 'for dev: check imported examples',
|
||||
};
|
||||
@@ -452,28 +460,32 @@ function renderOptions() {
|
||||
|
||||
let isDefaultSite = defaultSites_domains.includes(domain);
|
||||
optionEl.text = isDefaultSite ? '*' : '';
|
||||
optionEl.text += key + ': ' + domain +
|
||||
(sites_custom[key]['allow_cookies'] > 0 ? ' | allow_cookies' : '') +
|
||||
(sites_custom[key]['remove_cookies'] > 0 ? ' | remove_cookies' : '') +
|
||||
(sites_custom[key]['useragent'] ? ' | useragent: ' + sites_custom[key]['useragent'] : '') +
|
||||
(sites_custom[key]['useragent_custom'] ? ' | useragent_custom' : '') +
|
||||
(sites_custom[key]['googlebot'] > 0 ? ' | googlebot' : '') +
|
||||
(sites_custom[key]['referer'] ? ' | referer: ' + sites_custom[key]['referer'] : '') +
|
||||
(sites_custom[key]['referer_custom'] ? ' | referer_custom' : '') +
|
||||
(sites_custom[key]['random_ip'] ? ' | random_ip: ' + sites_custom[key]['random_ip'] : '') +
|
||||
((sites_custom[key]['block_js'] > 0 || sites_custom[key]['block_javascript'] > 0) ? ' | block_js' : '') +
|
||||
((sites_custom[key]['block_js_ext'] > 0 || sites_custom[key]['block_javascript_ext'] > 0) ? ' | block_js_ext' : '') +
|
||||
(sites_custom[key]['block_js_inline'] ? ' | block_js_inline' : '') +
|
||||
(sites_custom[key]['block_regex'] ? ' | block_regex' : '') +
|
||||
(sites_custom[key]['amp_unhide'] > 0 ? ' | amp_unhide' : '') +
|
||||
(sites_custom[key]['amp_redirect'] ? ' | amp_redirect' : '') +
|
||||
(sites_custom[key]['ld_json'] ? ' | ld_json' : '') +
|
||||
(sites_custom[key]['ld_json_next'] ? ' | ld_json_next' : '') +
|
||||
(sites_custom[key]['ld_json_url'] ? ' | ld_json_url' : '') +
|
||||
(sites_custom[key]['ld_archive_is'] ? ' | ld_archive_is' : '') +
|
||||
(sites_custom[key]['ld_google_webcache'] ? ' | ld_google_webcache' : '') +
|
||||
(sites_custom[key]['add_ext_link'] && sites_custom[key]['add_ext_link_type'] ? ' | add_ext_link' : '') +
|
||||
(sites_custom[key]['cs_code'] ? ' | cs_code' : '');
|
||||
optionEl.text += key;
|
||||
if (!navigator_ua_mobile) {
|
||||
optionEl.text += ': ' + domain +
|
||||
(sites_custom[key]['allow_cookies'] > 0 ? ' | allow_cookies' : '') +
|
||||
(sites_custom[key]['remove_cookies'] > 0 ? ' | remove_cookies' : '') +
|
||||
(sites_custom[key]['cs_clear_lclstrg'] > 0 ? ' | cs_clear_lclstrg' : '') +
|
||||
(sites_custom[key]['useragent'] ? ' | useragent: ' + sites_custom[key]['useragent'] : '') +
|
||||
(sites_custom[key]['useragent_custom'] ? ' | useragent_custom' : '') +
|
||||
(sites_custom[key]['googlebot'] > 0 ? ' | googlebot' : '') +
|
||||
(sites_custom[key]['referer'] ? ' | referer: ' + sites_custom[key]['referer'] : '') +
|
||||
(sites_custom[key]['referer_custom'] ? ' | referer_custom' : '') +
|
||||
(sites_custom[key]['random_ip'] ? ' | random_ip: ' + sites_custom[key]['random_ip'] : '') +
|
||||
((sites_custom[key]['block_js'] > 0) ? ' | block_js' : '') +
|
||||
((sites_custom[key]['block_js_ext'] > 0) ? ' | block_js_ext' : '') +
|
||||
(sites_custom[key]['block_js_inline'] ? ' | block_js_inline' : '') +
|
||||
(sites_custom[key]['block_regex'] ? ' | block_regex' : '') +
|
||||
(sites_custom[key]['amp_unhide'] > 0 ? ' | amp_unhide' : '') +
|
||||
(sites_custom[key]['amp_redirect'] ? ' | amp_redirect' : '') +
|
||||
(sites_custom[key]['ld_json'] ? ' | ld_json' : '') +
|
||||
(sites_custom[key]['ld_json_next'] ? ' | ld_json_next' : '') +
|
||||
(sites_custom[key]['ld_json_source'] ? ' | ld_json_source' : '') +
|
||||
(sites_custom[key]['ld_json_url'] ? ' | ld_json_url' : '') +
|
||||
(sites_custom[key]['ld_archive_is'] ? ' | ld_archive_is' : '') +
|
||||
(sites_custom[key]['add_ext_link'] && sites_custom[key]['add_ext_link_type'] ? ' | add_ext_link' : '') +
|
||||
(sites_custom[key]['cs_code'] ? ' | cs_code' : '');
|
||||
}
|
||||
optionEl.value = key;
|
||||
selectEl.add(optionEl);
|
||||
}
|
||||
@@ -498,6 +510,19 @@ function renderOptions() {
|
||||
perm_custom.innerText = 'NO';
|
||||
}
|
||||
});
|
||||
|
||||
var sites_custom_upd_version = items.sites_custom_upd_version;
|
||||
if (sites_custom['###_remove_sites'] && sites_custom['###_remove_sites'].cs_code) {
|
||||
let custom_version = '';
|
||||
let match = sites_custom['###_remove_sites'].cs_code.split(/,\s?/).filter(x => x.match(/^###_custom_/));
|
||||
if (match.length)
|
||||
custom_version = match[0].replace('###_custom_', '');
|
||||
if (custom_version < sites_custom_upd_version) {
|
||||
var custom_update = document.getElementById('custom-update');
|
||||
custom_update.style = 'font-weight: bold; color: red; margin: 20px 0px;';
|
||||
custom_update.innerText = 'Custom sites updated (import from local/online)!\r\n';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var custom_enabled = document.getElementById('custom-enabled');
|
||||
@@ -542,7 +567,8 @@ document.getElementById('sort').addEventListener('click', sort_options);
|
||||
document.getElementById('export').addEventListener('click', export_options);
|
||||
document.getElementById('import').onclick = function () {importInput.click()}
|
||||
document.getElementById('importInput').addEventListener("change", import_options, false);
|
||||
document.getElementById('import_online').addEventListener('click', import_online_options);
|
||||
document.getElementById('import_local').addEventListener('click', e => import_url_options(e, false));
|
||||
document.getElementById('import_online').addEventListener('click', e => import_url_options(e, true));
|
||||
document.getElementById('add').addEventListener('click', add_options);
|
||||
document.getElementById('delete').addEventListener('click', delete_options);
|
||||
document.getElementById('delete_default').addEventListener('click', delete_default_options);
|
||||
|
||||
@@ -6,25 +6,22 @@
|
||||
<link rel="stylesheet" href="options_all.css"/>
|
||||
<link rel="stylesheet" href="popup_switch.css"/>
|
||||
<style>
|
||||
body {
|
||||
text-align: center;
|
||||
}
|
||||
div {
|
||||
margin: 10px;
|
||||
}
|
||||
body {text-align: center;}
|
||||
div {margin: 10px;}
|
||||
</style>
|
||||
</head>
|
||||
<body style="width:290px">
|
||||
<div><strong>Bypass Paywalls Clean <span id="version"></span></strong><span id="site_switch_span"> </span></div>
|
||||
<div><a href="options.html" target="_blank">Options</a> |
|
||||
<a href="options_custom.html" target="_blank">Custom</a> |
|
||||
<a href="/README.html" target="_blank">Help</a> |
|
||||
<a href="https://twitter.com/Magnolia1234B" target="_blank">X (Twitter)</a></div>
|
||||
<div><a href="/changelog.txt" target="_blank">Changelog</a> |
|
||||
<button id="clear_cookies" title="clear cookies (and local storage) for current site">clear cookies<br>(& permission)</button> |
|
||||
<body style="width:300px">
|
||||
<div><strong>Bypass Paywalls Clean <span id="version"></span></strong><span id="site_switch_span"> </span></div>
|
||||
<div><a href="options.html" target="_blank">Options</a>
|
||||
<a href="options_custom.html" target="_blank">Custom</a>
|
||||
<a href="/README.html" target="_blank">Help</a>
|
||||
<a href="https://x.com/Magnolia1234B" target="_blank">X</a>
|
||||
<a href="https://xcancel.com/Magnolia1234B" target="_blank">Nitter</a></div>
|
||||
<div><a href="https://gitflic.ru/project/magnolia1234/bypass-paywalls-chrome-clean/blob/raw?file=changelog.txt" target="_blank">Changelog</a>
|
||||
<button id="clear_cookies" title="clear cookies (and local storage) for current site">clear site-cookies<br>(& ask permission)</button>
|
||||
<button id="button-close" title="close popup">close</button></div>
|
||||
<div><span id="version_new"></span></div>
|
||||
<div><span>* for unlisted sites: first clear cookies (X = no fix) & block general paywall-scripts (in options) or use custom sites/reader view</span></div>
|
||||
<div><span>* for unlisted sites: first clear cookies for site (X = no fix) & block general paywall-scripts (in options) or use custom sites/reader view</span></div>
|
||||
<div><span id="archive"></span></div>
|
||||
<script id="popup" src="version.js"></script>
|
||||
<script src="popup.js"></script>
|
||||
|
||||
@@ -1,13 +1,35 @@
|
||||
var ext_api = (typeof browser === 'object') ? browser : chrome;
|
||||
var url_loc = (typeof browser === 'object') ? 'firefox' : 'chrome';
|
||||
var manifestData = ext_api.runtime.getManifest();
|
||||
var navigator_ua = navigator.userAgent;
|
||||
var navigator_ua_mobile = navigator_ua.toLowerCase().includes('mobile');
|
||||
var yandex_browser = navigator_ua_mobile && (url_loc === 'chrome') && navigator_ua.toLowerCase().includes('yabrowser');
|
||||
var custom_switch = ((manifestData.optional_permissions && manifestData.optional_permissions.length) || (manifestData.optional_host_permissions && manifestData.optional_host_permissions.length)) && !(navigator_ua_mobile && (url_loc === 'chrome') && !yandex_browser);
|
||||
var ext_manifest_version = manifestData.manifest_version;
|
||||
var custom_switch = ((manifestData.optional_permissions && manifestData.optional_permissions.length) || (manifestData.optional_host_permissions && manifestData.optional_host_permissions.length));
|
||||
|
||||
// htmlviewer: clean layout
|
||||
ext_api.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true
|
||||
}, function (tabs) {
|
||||
if (tabs && tabs[0] && ((tabs[0].url === 'about:blank' && tabs[0].title !== 'about:blank') || tabs[0].url === 'https://codebeautify.org/htmlviewer')) {
|
||||
let tabId = tabs[0].id;
|
||||
if (ext_manifest_version === 2) {
|
||||
ext_api.tabs.executeScript(tabId, {
|
||||
file: '/options/htmlviewer.js'
|
||||
}, function (res) {
|
||||
if (ext_api.runtime.lastError || res[0]) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
} else if (ext_manifest_version === 3) {
|
||||
ext_api.scripting.executeScript({
|
||||
target: {tabId: tabId},
|
||||
files: ["/options/htmlviewer.js"]
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function popup_show_toggle(domain, enabled) {
|
||||
if (domain && !matchDomain(['webcache.googleusercontent.com'], domain)) {
|
||||
if (domain) {
|
||||
var site_switch_span = document.getElementById('site_switch_span');
|
||||
let labelEl = document.createElement('label');
|
||||
labelEl.setAttribute('class', 'switch');
|
||||
@@ -82,17 +104,12 @@ function showArchiveLinks() {
|
||||
if (tabs && tabs[0] && /^http/.test(tabs[0].url)) {
|
||||
let url = tabs[0].url;
|
||||
let hostname = urlHost(url);
|
||||
if (!matchDomain(['hbrchina.org'], hostname))
|
||||
url = url.split(/[#\?]/)[0];
|
||||
let url_enc = encodeURIComponent(url);
|
||||
let archive_array = {
|
||||
'Archive.today': 'https://archive.today?run=1&url=' + url_enc,
|
||||
'Google webcache': 'https://webcache.googleusercontent.com/search?q=cache:' + url_enc,
|
||||
'Clearthis.page': 'https://clearthis.page?u=' + url,
|
||||
'1ft.io': 'https://1ft.io/' + url,
|
||||
'Google Search Tool\n(use online html-viewer - no fix)': 'https://search.google.com/test/rich-results?url=' + url_enc
|
||||
'Clearthis.page': 'https://clearthis.page?u=' + url_enc,
|
||||
'Google Search Tool\n(see help - troubleshooting)': 'https://search.google.com/test/rich-results?url=' + url_enc
|
||||
};
|
||||
//'Archive.today (renew)': 'https://archive.today?renew=1&url=' + url_enc,
|
||||
let archive_id = document.querySelector('span#archive');
|
||||
if (archive_id) {
|
||||
archive_id.appendChild(document.createTextNode('Open tab in:'));
|
||||
@@ -100,7 +117,7 @@ function showArchiveLinks() {
|
||||
let elem_div = document.createElement('div');
|
||||
let elem = document.createElement('a');
|
||||
elem.innerText = key;
|
||||
if (!(matchDomain(['1ft.io', 'clearthis.page', 'google.com', 'googleusercontent.com'], hostname) || hostname.match(/^archive\.\w{2}$/))) {
|
||||
if (!(matchDomain(['clearthis.page', 'google.com'], hostname) || hostname.match(/^archive\.\w{2}$/))) {
|
||||
elem.href = archive_array[key];
|
||||
elem.title = elem.href;
|
||||
elem.target = '_blank';
|
||||
@@ -115,11 +132,9 @@ function showArchiveLinks() {
|
||||
showArchiveLinks();
|
||||
|
||||
function matchDomain(domains, hostname = window.location.hostname) {
|
||||
let matched_domain = false;
|
||||
if (typeof domains === 'string')
|
||||
domains = [domains];
|
||||
domains.some(domain => (hostname === domain || hostname.endsWith('.' + domain)) && (matched_domain = domain));
|
||||
return matched_domain;
|
||||
return domains.find(domain => hostname === domain || hostname.endsWith('.' + domain)) || false;
|
||||
}
|
||||
|
||||
function urlHost(url) {
|
||||
|
||||
@@ -2,7 +2,7 @@ var ext_api = (typeof browser === 'object') ? browser : chrome;
|
||||
|
||||
var manifestData = ext_api.runtime.getManifest();
|
||||
var url_loc = manifestData.key ? 'chrome' : 'firefox';
|
||||
var ext_url = 'https://github.com/bpc-clone/bpc_updates/releases/latest';
|
||||
var ext_url = 'https://gitflic.ru/project/magnolia1234/bpc_uploads';
|
||||
var ext_name = manifestData.name;
|
||||
var version_str = 'v' + manifestData.version;
|
||||
var version_span = document.querySelector('span#version');
|
||||
@@ -28,6 +28,7 @@ function show_warning() {
|
||||
version_span_new.appendChild(par);
|
||||
}
|
||||
}
|
||||
|
||||
function show_update(ext_version_new, check = true) {
|
||||
if (ext_version_new) {
|
||||
ext_api.management.getSelf(function (result) {
|
||||
@@ -42,7 +43,7 @@ function show_update(ext_version_new, check = true) {
|
||||
if (installType === 'development')
|
||||
anchorEl.href = ext_url;
|
||||
else {
|
||||
anchorEl.href = ext_url + '/-/releases';
|
||||
anchorEl.href = ext_url;
|
||||
ext_version_new = ext_version_new.replace(/\d$/, '0');
|
||||
}
|
||||
anchorEl.innerText = 'New release v' + ext_version_new;
|
||||
@@ -52,8 +53,8 @@ function show_update(ext_version_new, check = true) {
|
||||
show_warning();
|
||||
} else if (check) {
|
||||
anchorEl = document.createElement('a');
|
||||
anchorEl.text = 'Check Twitter for latest update';
|
||||
anchorEl.href = 'https://twitter.com/Magnolia1234B';
|
||||
anchorEl.text = 'Check X/Twitter for latest update';
|
||||
anchorEl.href = 'https://x.com/Magnolia1234B';
|
||||
anchorEl.target = '_blank';
|
||||
version_span_new.appendChild(anchorEl);
|
||||
}
|
||||
@@ -61,20 +62,10 @@ function show_update(ext_version_new, check = true) {
|
||||
|
||||
function check_version_update(ext_version_new, popup) {
|
||||
if (!popup) {
|
||||
let manifest_new = 'https://bitbucket.org/bpc-updates/bpc_updates/downloads/manifest.json';
|
||||
fetch(manifest_new)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
response.json().then(json => {
|
||||
var version_new = json['version'];
|
||||
show_update(version_new);
|
||||
})
|
||||
} else {
|
||||
show_update(ext_version_new);
|
||||
}
|
||||
}).catch(function (err) {
|
||||
false;
|
||||
ext_api.runtime.sendMessage({
|
||||
request: 'check_update'
|
||||
});
|
||||
show_update(ext_version_new);
|
||||
} else
|
||||
show_update(ext_version_new, false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user