diff --git a/README.md b/README.md index 147d88ca..e5364e09 100644 --- a/README.md +++ b/README.md @@ -409,7 +409,7 @@ Grouped in options:\ ##### United Kingdom/Ireland [Belfast Telegraph](https://www.belfasttelegraph.co.uk) - -[Business Post (link to archive.is)](https://www.businesspost.ie) - +[Business Post](https://www.businesspost.ie) - [Citywire](https://www.citywire.com) - [Euromoney](https://www.euromoney.com) - [Evening Standard](https://www.standard.co.uk) - diff --git a/changelog.txt b/changelog.txt index cf2b29e2..a0d8bd22 100644 --- a/changelog.txt +++ b/changelog.txt @@ -9,6 +9,7 @@ Add Stuttgarter-zeitung.de Remove Golem.de (fix obsolete) Remove LeFigaro.fr (fix obsolete) Remove Tagesspiegel.de (fix obsolete) +Fix BusinessPost.ie (json) Fix Hearst Communications magazines (js) Fix Midi-Olympique.fr (new domain Rugbyrama.fr) diff --git a/contentScript.js b/contentScript.js index 7444d084..0db22744 100644 --- a/contentScript.js +++ b/contentScript.js @@ -266,6 +266,27 @@ if (ext_api.runtime) { }) } +window.addEventListener('message', function (event) { + if (event.data) { + if (event.data.type === 'from_page') { + if (matchDomain('businesspost.ie')) { + let data = event.data.data; + let article = document.querySelector('div.article-body-section'); + if (data && article && dompurify_loaded && !msg_once) { + msg_once = true; + let parser = new DOMParser(); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(data) + '
', 'text/html'); + let article_new = doc.querySelector('div'); + if (article_new) { + article.innerHTML = ''; + article.appendChild(article_new); + } + } + } + } + } +}, false); + var div_bpc_done = document.querySelector('div#bpc_done'); if (!div_bpc_done) { @@ -2611,14 +2632,47 @@ if (matchDomain(['belfasttelegraph.co.uk', 'independent.ie'])) { } else if (matchDomain('businesspost.ie')) { - let url = window.location.href; - let paywall = document.querySelector('div#bp_paywall_content'); - if (paywall) { - removeDOMElement(paywall); - let article = document.querySelector('div.article-body-section'); - if (article) - article.firstChild.before(archiveLink(url)); + function bpie_main() { + if ($) { + let article_id_dom = document.querySelector('article[id]'); + let article_id; + if (article_id_dom) + article_id = article_id_dom.id; + if (article_id) { + let bp_ajaxurl = 'https://www.businesspost.ie/wp-admin/admin-ajax.php'; + let data_ajax = { + action: 'fetch_article_content', + type: 'POST', + data: { + id: article_id + }, + dataType: 'json', + contentType: 'application/json' + }; + $.ajax({ + type: 'POST', + url: bp_ajaxurl, + data: data_ajax, + success: function (data) { + window.postMessage({type: 'from_page', data: data}); + } + }); + } + } else + window.location.reload(true); } + csDoneOnce = true; + window.setTimeout(function () { + let paywall = document.querySelector('div#bp_paywall_content'); + let article_id_dom = document.querySelector('article[id]'); + let article_id; + if (article_id_dom) + article_id = article_id_dom.id; + if (paywall || article_id) { + removeDOMElement(paywall); + insert_script(bpie_main); + } + }, 500); } else if (matchDomain('citywire.com')) { diff --git a/custom/manifest.json b/custom/manifest.json index 5836b394..25a96932 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -51,5 +51,5 @@ "webRequestBlocking", "*://*/*" ], - "version": "3.2.3.3" + "version": "3.2.3.4" } diff --git a/manifest.json b/manifest.json index b99c2e47..3b7291e4 100644 --- a/manifest.json +++ b/manifest.json @@ -761,5 +761,5 @@ "*://*.wyleex.com/*", "*://webcache.googleusercontent.com/*" ], - "version": "3.2.3.3" + "version": "3.2.3.4" } diff --git a/sites.js b/sites.js index fccedbc7..692fdb26 100644 --- a/sites.js +++ b/sites.js @@ -277,10 +277,11 @@ var defaultSites = { allow_cookies: 1, block_regex: /(\.tinypass\.com\/|cdn\.ampproject\.org\/v\d\/amp-access-.+\.js)/ }, - "Business Post.ie (link to archive.is)": { + "Business Post.ie": { domain: "businesspost.ie", allow_cookies: 1, - block_regex: /\.piano\.io\// + block_regex: /\.piano\.io\//, + cs_dompurify: 1 }, "California Business Journals": { domain: "###_usa_cbj",