diff --git a/changelog.txt b/changelog.txt index 26a150b8..8a6eab0e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -12,6 +12,7 @@ Add Welt.de (link to archive.is) Remove EurekaReport.com.au (domain obsolete) Fix FreiePresse.de Fix South China Morning Post (css) +Fix Tech in Asia (css) * v3.4.2.0 (2023-11-12) Add Haymarket Media Group (opt-in to custom sites) diff --git a/contentScript.js b/contentScript.js index 6197e5a5..464a9941 100644 --- a/contentScript.js +++ b/contentScript.js @@ -4783,31 +4783,37 @@ else if (matchDomain('swarajyamag.com')) { } else if (matchDomain('techinasia.com')) { - let paywall = document.querySelector('.paywall-content'); - if (paywall && dompurify_loaded) { - paywall.classList.remove('paywall-content'); - let url = window.location.href; - let url_xhr = url.replace('.com/', '.com/wp-json/techinasia/2.0/posts/').replace('/visual-story/', '/'); - fetch(url_xhr) - .then(response => { - if (response.ok) { - response.json().then(json => { - let json_text = json.posts[0].content; - json_text = json_text.replace(/width\=\"(\d){3,}\"/g, 'width="100%"').replace(/height\=\"(\d){3,}\"/g, 'height="100%"'); - let content = document.querySelector('div.content'); - if (json_text && content) { - let parser = new DOMParser(); - let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text) + '
', 'text/html'); - let content_new = doc.querySelector('div.content'); - content.parentNode.replaceChild(content_new, content); + window.setTimeout(function () { + let paywall = document.querySelector('div.paywall-content'); + if (paywall && dompurify_loaded) { + paywall.classList.remove('paywall-content'); + let par_missing = paywall.querySelectorAll('div[id^="attachment_"], a.flourish-credit'); + let attach_xhr = Array.from(par_missing).some(x => !x.hasChildNodes()); + if (attach_xhr) { + let url = window.location.href; + let url_xhr = url.replace('.com/', '.com/wp-json/techinasia/2.0/posts/').replace('/visual-story/', '/'); + fetch(url_xhr) + .then(response => { + if (response.ok) { + response.json().then(json => { + let json_text = json.posts[0].content; + json_text = json_text.replace(/width\=\"(\d){3,}\"/g, 'width="100%"').replace(/height\=\"(\d){3,}\"/g, 'height="100%"'); + let content = document.querySelector('div.content'); + if (json_text && content) { + let parser = new DOMParser(); + let doc = parser.parseFromString('
' + DOMPurify.sanitize(json_text) + '
', 'text/html'); + let content_new = doc.querySelector('div.content'); + content.parentNode.replaceChild(content_new, content); + } + }); } }); } - }); - } - let splash_subscribe = document.querySelector('.splash-subscribe'); - let paywall_hard = document.querySelector('.paywall-hard'); - removeDOMElement(splash_subscribe, paywall_hard); + } + let splash_subscribe = document.querySelector('div.splash-subscribe'); + let paywall_hard = document.querySelector('div.paywall-hard'); + removeDOMElement(splash_subscribe, paywall_hard); + }, 3000); } else if (matchDomain(['techtarget.com', 'computerweekly.com', 'lemagit.fr'])) { diff --git a/custom/manifest.json b/custom/manifest.json index 2e019a0a..5387f7a8 100644 --- a/custom/manifest.json +++ b/custom/manifest.json @@ -51,5 +51,5 @@ "webRequestBlocking", "*://*/*" ], - "version": "3.4.2.8" + "version": "3.4.2.9" } diff --git a/manifest.json b/manifest.json index 51a39ded..749d6db0 100644 --- a/manifest.json +++ b/manifest.json @@ -815,5 +815,5 @@ "*://*.wyleex.com/*", "*://webcache.googleusercontent.com/*" ], - "version": "3.4.2.8" + "version": "3.4.2.9" }