From d562914762bef743e485abddd230385c65741551 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sun, 5 Jan 2020 17:16:32 +0100 Subject: [PATCH] Fix Australian Financial Review Eenable Javascript/photos. --- background.js | 5 +++-- contentScript.js | 16 ++++++++++++++++ manifest.json | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index 7b9e26e..d316dba 100644 --- a/background.js +++ b/background.js @@ -258,7 +258,8 @@ const blockedRegexes = { 'foreignpolicy.com': /.+\.tinypass\.com\/.+/, 'inquirer.com': /.+\.tinypass\.com\/.+/, 'spectator.co.uk': /.+\.tinypass\.com\/.+/, -'newcastleherald.com.au': /.+cdn-au\.piano\.io\/api\/tinypass.+\.js/ +'newcastleherald.com.au': /.+cdn-au\.piano\.io\/api\/tinypass.+\.js/, +'afr.com': /afr\.com\/assets\/vendorsReactRedux_client.+\.js/ }; const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" @@ -307,7 +308,7 @@ chrome.webRequest.onBeforeRequest.addListener(function(details) { return {cancel: true}; }, { - urls: ["*://*.theglobeandmail.com/*", "*://*.newstatesman.com/*", "*://*.afr.com/*"], + urls: ["*://*.theglobeandmail.com/*", "*://*.newstatesman.com/*"], types: ["script"] }, ["blocking"] diff --git a/contentScript.js b/contentScript.js index c4ab096..19a32fc 100644 --- a/contentScript.js +++ b/contentScript.js @@ -257,6 +257,22 @@ if (window.location.href.indexOf("thestar.com") !== -1) { } } +if (window.location.href.indexOf("afr.com") !== -1) { + document.addEventListener('DOMContentLoaded', () => { + const hidden_image = document.querySelectorAll('img'); + for (let i = 0; i < hidden_image.length; i++) { + var src = hidden_image[i].src; + if ('src: ' + src.indexOf(".gif") !== -1) { + var data_src = hidden_image[i].getAttribute("data-src"); + if (data_src) + hidden_image[i].setAttribute('src', data_src); + } + } + const plista = document.querySelector('div[data-plista-placement="underArticle_Group"]'); + removeDOMElement(plista); + }); +} + function removeDOMElement(...elements) { for (let element of elements) { if (element) element.remove(); diff --git a/manifest.json b/manifest.json index ed38bc7..5eaeaf7 100644 --- a/manifest.json +++ b/manifest.json @@ -28,7 +28,8 @@ "*://*.theathletic.com/*", "*://*.techinasia.com/*", "*://*.newcastleherald.com.au/*", - "*://*.thestar.com/*" + "*://*.thestar.com/*", + "*://*.afr.com/*" ], "js": ["contentScript.js"] }