From 6b8c669a13de77d8d12c5ef79e05197948a00aef Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Wed, 20 Dec 2023 09:06:44 +0100 Subject: [PATCH] Add Rp.pl Update ld_json_url (default url) --- README.md | 3 +++ changelog.txt | 2 ++ contentScript.js | 47 +++++++++++++++++++++++++--------------- custom/manifest.json | 2 +- custom/sites_custom.json | 22 +++---------------- manifest.json | 3 ++- options/options.js | 5 +---- options/version.js | 12 ++++++++-- sites.js | 4 ++++ sites_updated.json | 5 +++++ 10 files changed, 61 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 53b1202..3152863 100644 --- a/README.md +++ b/README.md @@ -766,6 +766,9 @@ Grouped in options:\ [TradeWinds](https://www.tradewindsnews.com) - [Upstream](https://www.upstreamonline.com) +##### Poland +[Rzeczpospolita](https://www.rp.pl) + ##### Portugal [Correio da Manhã](https://www.cmjornal.pt) - [Record](https://www.record.pt) - diff --git a/changelog.txt b/changelog.txt index 997d183..88043d5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,7 @@ Updates (install signed xpi-file): https://gitlab.com/magnolia1234/bypass-paywal Post-release Add Bild.de (link to archive.is) +Add Rp.pl Remove Money.it (fix obsolete) Fix Automobilwoche.de (js) Fix Groupe Centre France (identify sites) @@ -14,6 +15,7 @@ Fix Media Group Westfalen Fix National Review (cookies) Fix NYmag-sites (js) Enable optional host permissions on Android (Firefox 120+) +Update ld_json_url (default url) * v3.4.7.0 (2023-12-14) Add Die Presse (at) diff --git a/contentScript.js b/contentScript.js index 83820ee..733f984 100644 --- a/contentScript.js +++ b/contentScript.js @@ -1438,8 +1438,12 @@ else if (matchDomain(de_madsack_domains) || document.querySelector('head > link[ } else if (matchDomain('ruhrnachrichten.de') || document.querySelector('a.mgw-logo[href^="https://mgw.de"]')) { + let pathname = window.location.pathname; + let article_id; + if (pathname.includes('-p-')) + article_id = pathname.split('-p-')[1].split('/')[0]; if (dompurify_loaded) - getJsonUrl('body.is_plus_article', {rm_class: 'is_plus_article'}, 'article'); + getJsonUrl('body.is_plus_article', {rm_class: 'is_plus_article'}, 'article', {art_append: 1, art_hold: 1}, article_id); let ads = document.querySelector('div.OUTBRAIN'); hideDOMElement(ads); if (!matchDomain('ruhrnachrichten.de')) { @@ -4568,6 +4572,11 @@ else if (matchDomain('quora.com')) { }, 500); } +else if (matchDomain('rp.pl')) { + let url = window.location.href; + getGoogleWebcache(url, 'div.paywallComponentWrapper', '', 'div.main--content--body'); +} + else if (matchDomain('rugbypass.com')) { if (window.location.pathname.startsWith('/plus/')) { let paywall = document.querySelector('.premium-fold-bottom'); @@ -6141,22 +6150,26 @@ function findKeyJson(json, keys, min_val_len = 0) { return source; } -function getJsonUrlText(article, callback) { +function getJsonUrlText(article, callback, article_id = '') { let json_url_dom = document.querySelector('head > link[rel="alternate"][type="application/json"][href]'); let json_url = json_url_dom.href; - fetch(json_url) - .then(response => { - if (response.ok) { - response.json().then(json => { - try { - let json_text = parseHtmlEntities(json.content.rendered); - callback(json_text, article); - } catch (err) { - console.log(err); - } - }); - } - }); + if (!json_url && article_id) + json_url = 'https://' + window.location.hostname + '/wp-json/wp/v2/posts/' + article_id; + if (json_url) { + fetch(json_url) + .then(response => { + if (response.ok) { + response.json().then(json => { + try { + let json_text = parseHtmlEntities(json.content.rendered); + callback(json_text, article); + } catch (err) { + console.log(err); + } + }); + } + }); + } } function getJsonUrlAdd(json_text, article, art_options = {}) { @@ -6185,7 +6198,7 @@ function getJsonUrlAdd(json_text, article, art_options = {}) { article.parentNode.replaceChild(article_new, article); } -function getJsonUrl(paywall_sel, paywall_action = '', article_sel, art_options = {}) { +function getJsonUrl(paywall_sel, paywall_action = '', article_sel, art_options = {}, article_id = '') { let paywall = document.querySelectorAll(paywall_sel); let article = document.querySelector(article_sel); if (paywall.length && article && dompurify_loaded) { @@ -6193,7 +6206,7 @@ function getJsonUrl(paywall_sel, paywall_action = '', article_sel, art_options = getJsonUrlText(article, (json_text, article) => { if (json_text && article) getJsonUrlAdd(json_text, article, art_options); - }); + }, article_id); } } diff --git a/custom/manifest.json b/custom/manifest.json index c36a9de..dd3f314 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -51,5 +51,5 @@ "webRequestBlocking", "*://*/*" ], - "version": "3.4.7.5" + "version": "3.4.7.6" } diff --git a/custom/sites_custom.json b/custom/sites_custom.json index 5e8c827..6bd83a0 100644 --- a/custom/sites_custom.json +++ b/custom/sites_custom.json @@ -1,6 +1,6 @@ { "###_remove_sites": { - "cs_code": "africaintelligence.fr, al-monitor.com, arkansasonline.com, bild.de, columbian.com, die-glocke.de, doorbraak.be, gp.se, intelligenceonline.com, intelligenceonline.fr, interestingengineering.com, jeuneafrique.com, lalettrea.fr, lastampa.it, lavozdegalicia.es, law360.com, lepoint.fr, limburger.nl, manager-magazin.de, ouest-france.fr, pressherald.com, repubblica.it, risk.net, saechsische.de, sueddeutsche.de, swarajyamag.com, theepochtimes.com, theinformation.com, thestage.co.uk, thetexan.news, theweek.com, vikatan.com", + "cs_code": "africaintelligence.fr, al-monitor.com, arkansasonline.com, bild.de, columbian.com, die-glocke.de, doorbraak.be, gp.se, handelsblatt.com, intelligenceonline.com, intelligenceonline.fr, interestingengineering.com, jeuneafrique.com, lalettrea.fr, lastampa.it, lavozdegalicia.es, law360.com, lepoint.fr, limburger.nl, manager-magazin.de, ouest-france.fr, politiken.dk, pressherald.com, repubblica.it, risk.net, saechsische.de, sueddeutsche.de, swarajyamag.com, theepochtimes.com, theinformation.com, thestage.co.uk, thetexan.news, theweek.com, vikatan.com", "domain": "###" }, "Abajournal.com": { @@ -81,10 +81,10 @@ "domain": "businessam.be" }, "Businessinsider.de": { - "add_ext_link": "div.piano-article__paywall|div.piano-article__content>p", + "add_ext_link": "div.piano-article__paywall|div.piano-article__content", "add_ext_link_type": "google_search_tool", "allow_cookies": 1, - "block_regex": "\\.tinypass\\.com", + "block_regex": "\\.piano\\.io", "domain": "businessinsider.de" }, "Businessnews.com.au": { @@ -275,12 +275,6 @@ "domain": "group_nation_media", "group": "monitor.co.ug,nation.africa,thecitizen.co.tz" }, - "Handelsblatt.com (refresh)": { - "add_ext_link": "app-paywall|app-storyline-paragraph", - "add_ext_link_type": "archive.is", - "allow_cookies": 1, - "domain": "handelsblatt.com" - }, "Hartenergy.com": { "allow_cookies": 1, "block_regex": "js\\.pelcro\\.com", @@ -540,12 +534,6 @@ "Physicsworld.com": { "domain": "physicsworld.com" }, - "Politiken.dk": { - "add_ext_link": "div.stopsign|div.article__body", - "add_ext_link_type": "google_search_tool", - "allow_cookies": 1, - "domain": "politiken.dk" - }, "Portfolio.hu": { "add_ext_link": "section.paywall|article", "add_ext_link_type": "archive.is", @@ -597,10 +585,6 @@ "allow_cookies": 1, "domain": "rp-online.de" }, - "Rp.pl": { - "domain": "rp.pl", - "ld_google_webcache": "div.paywallComponentWrapper|div.main--content--body" - }, "Schwaebische-post.de": { "allow_cookies": 1, "block_regex": "\\.schwaebische-post\\.de\\/sub\\/js\\/pc-offer-west\\.js", diff --git a/manifest.json b/manifest.json index 5d1509e..ca98683 100644 --- a/manifest.json +++ b/manifest.json @@ -573,6 +573,7 @@ "*://*.rnd.de/*", "*://*.roadandtrack.com/*", "*://*.rollingstone.com/*", + "*://*.rp.pl/*", "*://*.rubbernews.com/*", "*://*.rugbypass.com/*", "*://*.rugbyrama.fr/*", @@ -823,5 +824,5 @@ "*://archive.vn/*", "*://webcache.googleusercontent.com/*" ], - "version": "3.4.7.5" + "version": "3.4.7.6" } diff --git a/options/options.js b/options/options.js index 081c197..d61b772 100644 --- a/options/options.js +++ b/options/options.js @@ -1,10 +1,7 @@ -// defaultSites are loaded from sites.js at installation extension (and are saved to local storage) -// var defaultSites = {}; -var ext_api = chrome || browser; +var ext_api = (typeof browser === 'object') ? browser : chrome; // Saves options to ext_api.storage function save_options() { - var gh_url = document.getElementById('bypass_sites').value; var inputEls = document.querySelectorAll('#bypass_sites input'); var sites = {}; diff --git a/options/version.js b/options/version.js index 8a86637..d7f6b7a 100644 --- a/options/version.js +++ b/options/version.js @@ -18,7 +18,9 @@ function show_update(ext_version_new, check = true) { ext_version_new: ext_version_new }); anchorEl = document.createElement('a'); - if (manifestData.applications && manifestData.applications.gecko.id.includes('magnolia')) { + anchorEl.target = '_blank'; + let manifest_id = manifestData.applications ? manifestData.applications.gecko.id : ''; + if (manifest_id && manifest_id.includes('magnolia')) { if (installType === 'development') anchorEl.href = 'https://gitlab.com/magnolia1234/bypass-paywalls-' + url_loc + '-clean'; else { @@ -31,9 +33,15 @@ function show_update(ext_version_new, check = true) { anchorEl.innerText = 'New release v' + ext_version_new; anchorEl.target = '_blank'; versionString_new.appendChild(anchorEl); + let warning; if (!manifestData.name.includes('Clean')) { + warning = 'fake'; + } else if (manifest_id && !manifest_id.match(/^magnolia(_limited_permissions)?@12\.34$/)) { + warning = 'cloned'; + } + if (warning) { let par = document.createElement('p'); - par.innerHTML = "You've installed a fake version of BPC (check GitLab)"; + par.innerHTML = "You've installed a " + warning + " version of BPC (check GitLab)"; versionString_new.appendChild(par); } } diff --git a/sites.js b/sites.js index 2905669..382b6d2 100644 --- a/sites.js +++ b/sites.js @@ -1964,6 +1964,10 @@ var defaultSites = { block_js_inline: /\.rugbypass\.com\/plus\//, block_regex: /\.tinypass\.com\// }, + "Rzeczpospolita": { + domain: "rp.pl", + cs_dompurify: 1 + }, "S&P Global": { domain: "spglobal.com", allow_cookies: 1, diff --git a/sites_updated.json b/sites_updated.json index 4dae2fb..4351fd0 100644 --- a/sites_updated.json +++ b/sites_updated.json @@ -70,6 +70,11 @@ "block_regex": "\\.cloudfront\\.net\\/embed\\/widget\\/subx.+\\.js", "upd_version": "3.4.7.6" }, + "Rzeczpospolita": { + "domain": "rp.pl", + "ld_google_webcache": "div.paywallComponentWrapper|div.main--content--body", + "upd_version": "3.4.7.6" + }, "The Economist": { "domain": "economist.com", "allow_cookies": 1,