Updated sites: add amp-redirect

merge-requests/2/head
magnolia1234 3 years ago
parent e015c4f61e
commit 1311b5e56f

@ -59,6 +59,8 @@ var blockedRegexes = {};
// unhide text on amp-page
var amp_unhide;
// redirect to amp-page
var amp_redirect;
// custom: block javascript
var block_js_custom = [];
@ -76,6 +78,7 @@ function initSetRules() {
use_twitter_referer = [];
change_headers = [];
amp_unhide = [];
amp_redirect = {};
block_js_custom = [];
block_js_custom_ext = [];
blockedRegexes = {};
@ -235,6 +238,9 @@ function set_rules(sites, sites_updated, sites_custom) {
break;
}
}
// updated
if (rule.amp_redirect)
amp_redirect[domain] = rule.amp_redirect;
// custom
if (rule.googlebot > 0)
use_google_bot.push(domain);
@ -920,6 +926,9 @@ if (matchUrlDomain(change_headers, details.url) && (!['font', 'image', 'styleshe
optin_setcookie: optin_setcookie,
amp_unhide: matchUrlDomain(amp_unhide, currentTabUrl)
};
let amp_redirect_domain = '';
if (amp_redirect_domain = matchUrlDomain(Object.keys(amp_redirect), currentTabUrl))
bg2csData.amp_redirect = amp_redirect[amp_redirect_domain];
ext_api.tabs.executeScript(tabId, {
code: 'var bg2csData = ' + JSON.stringify(bg2csData) + ';'
}, function () {

@ -5,6 +5,7 @@ Post-release
Add Advance Local (local USA)
Add Italian.tech
Fix Medium (faster)
Updated sites: add amp-redirect
* v2.4.4.0 (2021-11-14)
Fix Nikkei Asian Review (cookies)

@ -53,12 +53,29 @@ if ((bg2csData !== undefined) && bg2csData.amp_unhide) {
let subscr_section = document.querySelectorAll('[subscriptions-section="content"]');
for (let elem of subscr_section)
elem.removeAttribute('subscriptions-section');
let content_hidden = document.querySelectorAll('[amp-access][amp-access-hide]');
for (elem of content_hidden)
elem.removeAttribute('amp-access-hide');
let amp_ads = document.querySelectorAll('amp-ad');
removeDOMElement(...amp_ads);
}
}, 500); // Delay (in milliseconds)
}
// updated sites: amp-redirect
if ((bg2csData !== undefined) && bg2csData.amp_redirect) {
window.setTimeout(function () {
let amp_page = document.querySelector('script[src^="https://cdn.ampproject.org/"]');
if (!amp_page) {
let paywall = true;
if (bg2csData.amp_redirect.paywall)
paywall = document.querySelector(bg2csData.amp_redirect.paywall);
let amphtml = document.querySelector('link[rel="amphtml"]');
if (paywall && amphtml) {
removeDOMElement(paywall);
window.location.href = amphtml.href;
}
}
let content_hidden = document.querySelectorAll('[amp-access][amp-access-hide]');
for (elem of content_hidden)
elem.removeAttribute('amp-access-hide');
let amp_ads = document.querySelectorAll('amp-ad');
removeDOMElement(...amp_ads);
}, 500); // Delay (in milliseconds)
}

@ -569,5 +569,5 @@
"*://*.wallkit.net/*",
"*://*.wsj.net/*"
],
"version": "2.4.4.2"
"version": "2.4.4.3"
}

@ -324,9 +324,9 @@ function renderOptions() {
labelEl.appendChild(document.createElement('label'));
labelEl.appendChild(document.createTextNode('Updated sites: ' + sites_updated_domains_new.join()));
custom_sitesEl.appendChild(labelEl);
perm_origins = perm_origins.concat(sites_updated_domains_new).map(x => '*://*.' + x + '/*');
}
perm_origins = perm_origins.concat(sites_updated_domains_new).map(x => '*://*.' + x + '/*');
var perm_custom = document.getElementById('perm-custom');
ext_api.permissions.contains({
origins: perm_origins
@ -337,7 +337,7 @@ function renderOptions() {
perm_custom.innerText = 'NO';
}
});
});
});
var custom_enabled = document.getElementById('custom-enabled');
ext_api.permissions.contains({

Loading…
Cancel
Save