Fix National Geographic USA (magazine/link to archive.is)

This commit is contained in:
magnolia1234 2021-06-30 18:20:20 +02:00
parent cee0cc0794
commit f907d2ee18
5 changed files with 75 additions and 16 deletions

View file

@ -4,7 +4,7 @@
var ext_api = (typeof browser === 'object') ? browser : chrome;
var ext_name = ext_api.runtime.getManifest().name;
const cs_limit_except = ['elespanol.com', 'faz.net', 'inkl.com', 'la-croix.com', 'nation.africa', 'newleftreview.org'];
const cs_limit_except = ['elespanol.com', 'faz.net', 'inkl.com', 'la-croix.com', 'nation.africa', 'nationalgeographic.com', 'newleftreview.org'];
var currentTabUrl = '';
var csDone = false;
@ -1232,7 +1232,7 @@ if (matchUrlDomain(change_headers, details.url) && (['main_frame', 'sub_frame',
if (tabId !== -1) {
ext_api.tabs.get(tabId, function (currentTab) {
if ((currentTab && isSiteEnabled(currentTab) && !(matchUrlDomain('nationalgeographic.com', currentTab.url) && !header_referer)) || medium_custom_domain || au_apn_site || au_swm_site) {
if ((currentTab && isSiteEnabled(currentTab)) || medium_custom_domain || au_apn_site || au_swm_site) {
if (currentTab.url !== currentTabUrl) {
csDone = false;
currentTabUrl = currentTab.url;

View file

@ -3,11 +3,11 @@ Changelog Bypass Paywalls Clean - Firefox
Post-release
Fix Augsburger Allgemeine
Fix National Geographic USA (magazine/link to archive.is)
Fix Quartz (link to archive.is)
Maintenance contentScript (sanitize html-input)
* v2.2.7.0 (2021-06-27)
Fix National Geographic USA
Remove Finance.si (obsolete)
Fix blocked referer
Update custom sites (set useragent Bingbot)

View file

@ -283,8 +283,8 @@ if (matchDomain('augsburger-allgemeine.de')) {
elem.src = amp_iframe.getAttribute('src');
elem.setAttribute('frameborder', '0');
if (amp_iframe.getAttribute('height') && amp_iframe.getAttribute('width')) {
elem.setAttribute('height') = amp_iframe.getAttribute('height');
elem.setAttribute('width') = amp_iframe.getAttribute('width');
elem.setAttribute('height', amp_iframe.getAttribute('height'));
elem.setAttribute('width', amp_iframe.getAttribute('width'));
}
amp_iframe.parentElement.insertBefore(elem, amp_iframe);
removeDOMElement(amp_iframe);
@ -397,7 +397,7 @@ else if (matchDomain('faz.net')) {
str = str.replace(/(?:^|[A-Za-z\"\“])(\.|\?|!)(?=[A-ZÖÜ\„\d][A-Za-zÀ-ÿ\„\d]{1,})/gm, "$&\n\n");
str = str.replace(/(([a-z]{2,}|[\"\“]))(?=[A-Z](?=[A-Za-zÀ-ÿ]+))/gm, "$&\n\n");
// exceptions: names with alternating lower/uppercase (no general fix)
let str_rep_arr = ['AstraZeneca', 'BaFin', 'BerlHG', 'BfArM', 'BilMoG', 'DiGA', 'EuGH', 'FinTechRat', 'GlaxoSmithKline', 'IfSG', 'medRxiv', 'PlosOne', 'StVO'];
let str_rep_arr = ['AstraZeneca', 'BaFin', 'BerlHG', 'BfArM', 'BilMoG', 'BioNTech', 'DiGA', 'EuGH', 'FinTechRat', 'GlaxoSmithKline', 'IfSG', 'medRxiv', 'PlosOne', 'StVO'];
let str_rep_split,
str_rep_src;
for (let str_rep of str_rep_arr) {
@ -2044,16 +2044,18 @@ else if (matchDomain('nation.africa')) {
}
else if (matchDomain('nationalgeographic.com')) {
function natgeo_func(node) {
removeDOMElement(node);
let body = document.querySelector('body[class]');
if (body) {
body.removeAttribute('class');
body.removeAttribute('style');
}
// plus code in contentScript_once.js
let url = window.location.href;
let archive_url = 'https://archive.is?url=' + url;
let subscribed = document.querySelector('.Article__Content--gated');
let overlay = document.querySelector('.Article__Content__Overlay--gated');
let msg = document.querySelector('div#bpc_archive');
if (subscribed && !msg) {
subscribed.appendChild(archiveLink(archive_url));
subscribed.setAttribute('style', 'overflow: visible !important;');
if (overlay)
overlay.classList.remove('Article__Content__Overlay--gated');
}
waitDOMElement('div[id^="fittPortal"]', 'DIV', natgeo_func, false);
csDone = true;
}
else if (matchDomain('nationalreview.com')) {

49
contentScript_once.js Normal file
View file

@ -0,0 +1,49 @@
//"use strict";
if (matchDomain('nationalgeographic.com')) {
function natgeo_func(node) {
removeDOMElement(node);
let body = document.querySelector('body[class]');
if (body) {
body.removeAttribute('class');
body.removeAttribute('style');
}
}
waitDOMElement('div[id^="fittPortal"]', 'DIV', natgeo_func, false);
}
function matchDomain(domains, hostname) {
var matched_domain = false;
if (!hostname)
hostname = window.location.hostname;
if (typeof domains === 'string')
domains = [domains];
domains.some(domain => (hostname === domain || hostname.endsWith('.' + domain)) && (matched_domain = domain));
return matched_domain;
}
function removeDOMElement(...elements) {
for (let element of elements) {
if (element)
element.remove();
}
}
function waitDOMElement(selector, tagName = '', callback, multiple = false) {
new window.MutationObserver(function (mutations) {
for (let mutation of mutations) {
for (let node of mutation.addedNodes) {
if (!tagName || (node.tagName === tagName)) {
if (node.matches(selector)) {
callback(node);
if (!multiple)
this.disconnect();
}
}
}
}
}).observe(document, {
subtree: true,
childList: true
});
}

View file

@ -37,6 +37,14 @@
"optional_permissions": [
"<all_urls>"
],
"content_scripts": [{
"matches": [
"*://*.nationalgeographic.com/*"
],
"run_at": "document_start",
"js": ["contentScript_once.js"]
}
],
"permissions": [
"cookies",
"storage",
@ -528,5 +536,5 @@
"*://*.wallkit.net/*",
"*://*.wsj.net/*"
],
"version": "2.2.7.3"
"version": "2.2.7.4"
}