mirror of
https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean.git
synced 2024-11-10 05:37:47 +01:00
Updated sites: add code to contentScript
This commit is contained in:
parent
2ad489512e
commit
4ed4d8d8ed
3 changed files with 36 additions and 3 deletions
|
@ -61,6 +61,8 @@ var blockedRegexes = {};
|
|||
var amp_unhide;
|
||||
// redirect to amp-page
|
||||
var amp_redirect;
|
||||
// code for contentScript
|
||||
var cs_code;
|
||||
|
||||
// custom: block javascript
|
||||
var block_js_custom = [];
|
||||
|
@ -79,6 +81,7 @@ function initSetRules() {
|
|||
change_headers = [];
|
||||
amp_unhide = [];
|
||||
amp_redirect = {};
|
||||
cs_code = {};
|
||||
block_js_custom = [];
|
||||
block_js_custom_ext = [];
|
||||
blockedRegexes = {};
|
||||
|
@ -241,6 +244,8 @@ function set_rules(sites, sites_updated, sites_custom) {
|
|||
// updated
|
||||
if (rule.amp_redirect)
|
||||
amp_redirect[domain] = rule.amp_redirect;
|
||||
if (rule.cs_code)
|
||||
cs_code[domain] = rule.cs_code;
|
||||
// custom
|
||||
if (rule.googlebot > 0)
|
||||
use_google_bot.push(domain);
|
||||
|
@ -929,6 +934,9 @@ if (matchUrlDomain(change_headers, details.url) && (!['font', 'image', 'styleshe
|
|||
let amp_redirect_domain = '';
|
||||
if (amp_redirect_domain = matchUrlDomain(Object.keys(amp_redirect), currentTabUrl))
|
||||
bg2csData.amp_redirect = amp_redirect[amp_redirect_domain];
|
||||
let cs_code_domain = '';
|
||||
if (cs_code_domain = matchUrlDomain(Object.keys(cs_code), currentTabUrl))
|
||||
bg2csData.cs_code = cs_code[cs_code_domain];
|
||||
ext_api.tabs.executeScript(tabId, {
|
||||
code: 'var bg2csData = ' + JSON.stringify(bg2csData) + ';'
|
||||
}, function () {
|
||||
|
|
|
@ -6,7 +6,7 @@ Add Advance Local (local USA)
|
|||
Add Italian.tech
|
||||
Add Spectator World
|
||||
Fix Medium (faster)
|
||||
Updated sites: add amp-redirect
|
||||
Updated sites: add amp-redirect/code to contentScript
|
||||
|
||||
* v2.4.4.0 (2021-11-14)
|
||||
Fix Nikkei Asian Review (cookies)
|
||||
|
|
|
@ -46,7 +46,7 @@ if ((bg2csData !== undefined) && bg2csData.optin_setcookie) {
|
|||
// custom sites: try to unhide text on amp-page
|
||||
if ((bg2csData !== undefined) && bg2csData.amp_unhide) {
|
||||
window.setTimeout(function () {
|
||||
let amp_page = document.querySelector('script[src^="https://cdn.ampproject.org/"]');
|
||||
let amp_page = document.querySelector('script[src^="https://cdn.ampproject.org/"]') && (window.location.hostname.match(/\/amp(\d)?\./) || window.location.pathname.match(/(\/amp\/|(_|-|\.)amp\.html$|-amp\d|\.amp$)/) || window.location.search.match(/\?(output(Type)?=)?amp/));
|
||||
if (amp_page) {
|
||||
let preview = document.querySelector('[subscriptions-section="content-not-granted"]');
|
||||
removeDOMElement(preview);
|
||||
|
@ -65,7 +65,7 @@ if ((bg2csData !== undefined) && bg2csData.amp_unhide) {
|
|||
// updated sites: amp-redirect
|
||||
if ((bg2csData !== undefined) && bg2csData.amp_redirect) {
|
||||
window.setTimeout(function () {
|
||||
let amp_page = document.querySelector('script[src^="https://cdn.ampproject.org/"]');
|
||||
let amp_page = document.querySelector('script[src^="https://cdn.ampproject.org/"]') && (window.location.hostname.match(/\/amp(\d)?\./) || window.location.pathname.match(/(\/amp\/|(_|-|\.)amp\.html$|-amp\d|\.amp$)/) || window.location.search.match(/\?(output(Type)?=)?amp/));
|
||||
if (!amp_page) {
|
||||
let paywall = true;
|
||||
if (bg2csData.amp_redirect.paywall)
|
||||
|
@ -79,6 +79,31 @@ if ((bg2csData !== undefined) && bg2csData.amp_redirect) {
|
|||
}, 500); // Delay (in milliseconds)
|
||||
}
|
||||
|
||||
function cs_code_elems(elems) {
|
||||
for (let elem of elems) {
|
||||
let elem_dom = document.querySelectorAll(elem.cond);
|
||||
for (let item of elem_dom) {
|
||||
if (elem.rm_elem)
|
||||
removeDOMElement(item);
|
||||
if (elem.rm_class) {
|
||||
let rm_class = elem.rm_class.split(',').map(x => x.trim());
|
||||
item.classList.remove(...rm_class);
|
||||
}
|
||||
if (elem.rm_attrib)
|
||||
item.removeAttribute(elem.rm_attrib);
|
||||
if (elem.elems)
|
||||
cs_code_elems(elem.elems);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// updated sites: cs_code
|
||||
if ((bg2csData !== undefined) && bg2csData.cs_code) {
|
||||
window.setTimeout(function () {
|
||||
cs_code_elems(bg2csData.cs_code);
|
||||
}, 1000); // Delay (in milliseconds)
|
||||
}
|
||||
|
||||
// Content workarounds/domain
|
||||
|
||||
if (matchDomain(['medium.com', 'towardsdatascience.com']) || document.querySelector('script[src^="https://cdn-client.medium.com/"]')) {
|
||||
|
|
Loading…
Reference in a new issue