From 5c23c20cbcd5f57046c3a71e95eea7d9bebfced2 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Tue, 31 Oct 2023 17:55:19 +0100 Subject: [PATCH] Fix WSJ (mobile) --- changelog.txt | 2 +- contentScript.js | 38 ++++++++++++++++++++++++-------------- custom/manifest.json | 2 +- manifest.json | 2 +- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/changelog.txt b/changelog.txt index 1985c41..355bd88 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,7 +4,7 @@ Updates (install signed xpi-file): https://gitlab.com/magnolia1234/bypass-paywal Post-release Add The Impression -Fix WSJ (Googlebot for cn/jp subdomain) +Fix WSJ (mobile & Googlebot for cn/jp subdomain) Update custom sites (link to 1ft.io) * v3.4.0.0 (2023-10-29) diff --git a/contentScript.js b/contentScript.js index 850a195..d3c87ab 100644 --- a/contentScript.js +++ b/contentScript.js @@ -5404,6 +5404,8 @@ else if (matchDomain('winnipegfreepress.com')) { } else if (matchDomain('wsj.com')) { + if (matchDomain('www.wsj.com')) + blockJsReferrer(); if (window.location.pathname.startsWith('/livecoverage/')) { window.setTimeout(function () { let paywall = document.querySelector('div#cx-lc-snippet'); @@ -5412,14 +5414,10 @@ else if (matchDomain('wsj.com')) { removeDOMElement(paywall); if (amphtml) { amp_redirect_not_loop(amphtml); - } else if (window.location.pathname.includes('/card/')) { - let article = document.querySelector('div > div[class*="-ParagraphContainer"]'); - if (article) { - let weblink = document.createElement('a'); - weblink.href = window.location.href.split('/card/')[0]; - weblink.innerText = 'BPC > full text in feed'; - article.parentNode.firstChild.before(weblink); - } + } else { + let fade = document.querySelectorAll('div[class*="-CardWrapper"]'); + for (let elem of fade) + elem.removeAttribute('class'); } } }, 1000); @@ -5445,12 +5443,15 @@ else if (matchDomain('wsj.com')) { let wsj_pro = snippet.querySelector('a[href^="https://wsjpro.com/"]'); let article = document.querySelector('article'); if (article) { - if (wsj_pro) - article.firstChild.before(googleSearchToolLink(window.location.href)); - else - article.firstChild.before(archiveLink(window.location.href)); - if (!mobile) - header_nofix(document.querySelector('div#bpc_archive'), 'BPC > hard refresh page (for Windows: Ctrl + Enter in address bar) or use link below'); + window.setTimeout(function () { + if (wsj_pro) { + article.firstChild.before(googleSearchToolLink(window.location.href)); + article.firstChild.before(archiveLink(window.location.href, 'BPC > Try for full article text (articles before 2023-10-28)')); + } else + article.firstChild.before(archiveLink(window.location.href)); + }, 500); + csDoneOnce = true; + waitDOMElement('div.paywall', 'DIV', node => hideDOMElement(...document.querySelectorAll('div#bpc_archive')), false); } } } @@ -5677,6 +5678,15 @@ function header_nofix(header, msg = 'BPC > no fix') { } } +function blockJsReferrer() { + if (document.head && !document.querySelector('head > meta[name="referrer"][content="no-referrer"]')) { + var meta = document.createElement('meta'); + meta.name = "referrer"; + meta.content = "no-referrer"; + document.head.appendChild(meta); + } +} + function replaceDomElementExt(url, proxy, base64, selector, text_fail = '', selector_source = selector) { if (proxy) { if (!text_fail) { diff --git a/custom/manifest.json b/custom/manifest.json index 4403780..53d1352 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -51,5 +51,5 @@ "webRequestBlocking", "*://*/*" ], - "version": "3.4.0.2" + "version": "3.4.0.3" } diff --git a/manifest.json b/manifest.json index e95a644..6c69b35 100644 --- a/manifest.json +++ b/manifest.json @@ -808,5 +808,5 @@ "*://*.wyleex.com/*", "*://webcache.googleusercontent.com/*" ], - "version": "3.4.0.2" + "version": "3.4.0.3" }