Add The Juggernaut

merge-requests/14/head
magnolia1234 1 year ago
parent ede516776b
commit 2dbd4b8f5b

@ -201,6 +201,7 @@ Grouped in options:\
[The Intercept](https://theintercept.com) -
[The Daily Beast](https://www.thedailybeast.com) -
[The Daily Wire](https://www.dailywire.com) -
[The Juggernaut](https://www.thejuggernaut.com) -
[The Nation](https://www.thenation.com) -
[The New Atlantis](https://www.thenewatlantis.com) -
[The New Republic](https://newrepublic.com) -

@ -5,6 +5,7 @@ Updates: https://gitlab.com/magnolia1234/bypass-paywalls-firefox-clean/-/release
Post-release
Add Defector
Add Euromoney
Add The Juggernaut
Remove Iltalehti.fi (fix obsolete)
Fix ilManifesto.it (timing)
Fix iPolitics.ca (refresh)

@ -4244,6 +4244,139 @@ else if (matchDomain('theinitium.com')) {
removeDOMElement(paywall);
}
else if (matchDomain(['thejuggernaut.com', 'jgnt.co'])) {
let paywall = pageContains('div.font-mono', /\Read this article and many more by subscribing today/);
if (paywall.length) {
removeDOMElement(paywall[0].parentNode);
let json_script = document.querySelector('script#__NEXT_DATA__');
if (json_script) {
try {
let json = JSON.parse(json_script.innerText);
if (json && json.props.pageProps.post) {
let url_next = json.query.slug;
if (url_next && !window.location.pathname.includes(url_next))
refreshCurrentTab();
let pars = json.props.pageProps.post.fields.textEssay.fields.body.content;
let article = document.querySelector('div.opacity-50');
if (article) {
article.innerHTML = '';
article.removeAttribute('class');
let par_first = true;
function attach_text(sub_item, elem) {
if (sub_item.value) {
let sub_elem = document.createElement('span');
sub_elem.innerText = sub_item.value;
if (sub_item.marks && sub_item.marks.length) {
let style = '';
for (let mark of sub_item.marks) {
if (mark.type === 'bold')
style += 'font-weight: bold;';
else if (mark.type === 'italic')
style += 'font-style: italic;';
else if (mark.type === 'underline')
style += 'text-decoration: underline;';
}
sub_elem.style = style;
}
elem.appendChild(sub_elem);
}
}
function attach_hyperlink(sub_item, elem) {
if (sub_item.content && sub_item.content[0] && sub_item.content[0].value && sub_item.data && sub_item.data.uri) {
let sub_elem = document.createElement('a');
sub_elem.href = sub_item.data.uri;
sub_elem.innerText = sub_item.content[0].value;
if (!matchUrlDomain(['thejuggernaut.com', 'jgnt.co'], sub_item.data.uri))
sub_elem.target = '_blank';
sub_elem.style = 'text-decoration: underline;';
elem.appendChild(sub_elem);
}
}
function attach_paragraph(par, elem) {
if (par.content && par.content.length) {
let span_elem = document.createElement('span');
for (let item of par.content) {
if (item.nodeType === 'text') {
attach_text(item, span_elem);
} else if (item.nodeType === 'hyperlink') {
attach_hyperlink(item, span_elem);
} else
console.log(item);
}
elem.appendChild(span_elem);
}
}
for (let par of pars) {
let elem = document.createElement('p');
if (['paragraph', 'heading-1'].includes(par.nodeType)) {
attach_paragraph(par, elem);
} else if (['blockquote'].includes(par.nodeType)) {
if (par.content && par.content.length) {
for (let item of par.content) {
if (item.nodeType === 'paragraph') {
elem.style = 'margin: 0px 20px; font-style: italic;';
attach_paragraph(item, elem);
} else
console.log(item);
}
}
} else if (par.nodeType === 'hr') {
elem.appendChild(document.createElement('hr'));
} else if (par.nodeType === 'embedded-asset-block') {
if (!par_first) {
if (par.data && par.data.target && par.data.target.fields) {
if (par.data.target.fields.file && par.data.target.fields.file.url) {
let figure = document.createElement('figure');
let img = document.createElement('img');
img.src = par.data.target.fields.file.url;
figure.appendChild(img);
if (par.data.target.fields.description) {
let caption = document.createElement('figcaption');
caption.innerText = par.data.target.fields.description;
figure.appendChild(caption);
}
elem.appendChild(figure);
}
}
} else
par_first = false;
} else if (par.nodeType === 'unordered-list') {
if (par.content && par.content.length) {
let ul = document.createElement('ul');
for (let item of par.content) {
if (item.nodeType === 'list-item') {
if (item.content) {
for (let sub_item_par of item.content) {
if (sub_item_par.nodeType === 'paragraph') {
let li = document.createElement('li');
attach_paragraph(sub_item_par, li);
ul.appendChild(li);
}
}
}
} else
console.log(item);
}
elem.appendChild(ul);
}
} else {
console.log(par);
}
if (elem.hasChildNodes) {
article.appendChild(document.createElement('br'));
article.appendChild(elem);
}
}
}
} else
refreshCurrentTab();
} catch (err) {
console.log(err);
}
}
}
}
else if (matchDomain('thelawyersdaily.ca')) {
if (window.location.pathname.startsWith('/amp/')) {
ampToHtml();
@ -4657,6 +4790,21 @@ function matchDomain(domains, hostname = window.location.hostname) {
return matched_domain;
}
function urlHost(url) {
if (/^http/.test(url)) {
try {
return new URL(url).hostname;
} catch (e) {
console.log(`url not valid: ${url} error: ${e}`);
}
}
return url;
}
function matchUrlDomain(domains, url) {
return matchDomain(domains, urlHost(url));
}
function replaceDomElementExt(url, proxy, base64, selector, text_fail = '', selector_source = selector) {
if (proxy) {
if (!text_fail) {

@ -51,5 +51,5 @@
"webRequestBlocking",
"*://*/*"
],
"version": "3.0.9.5"
"version": "3.0.9.6"
}

@ -326,6 +326,7 @@
"*://*.italian.tech/*",
"*://*.italiaoggi.it/*",
"*://*.japantimes.co.jp/*",
"*://*.jgnt.co/*",
"*://*.journaldunet.com/*",
"*://*.journalnow.com/*",
"*://*.jpost.com/*",
@ -611,6 +612,7 @@
"*://*.thehindubusinessline.com/*",
"*://*.theinitium.com/*",
"*://*.theintercept.com/*",
"*://*.thejuggernaut.com/*",
"*://*.thelawyersdaily.ca/*",
"*://*.themarker.com/*",
"*://*.themarket.ch/*",
@ -738,5 +740,5 @@
"*://*.wallkit.net/*",
"*://webcache.googleusercontent.com/*"
],
"version": "3.0.9.5"
"version": "3.0.9.6"
}

@ -1951,6 +1951,14 @@ var defaultSites = {
allow_cookies: 1,
block_regex: /\.jpost\.com\/js\/js_article\.min\.js/
},
"The Juggernaut": {
domain: "###_usa_thejuggernaut",
group: [
"thejuggernaut.com",
"jgnt.co"
],
allow_cookies: 1
},
"The Lawyer's Daily": {
domain: "thelawyersdaily.ca",
allow_cookies: 1,

Loading…
Cancel
Save