From 4479d243a14dcf46d324566848f27d003349aca7 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sun, 5 Jan 2020 17:23:28 +0100 Subject: [PATCH] Fix Globe and Mail Enable Javascript/photos, no video and photo gallery though --- background.js | 5 +++-- contentScript.js | 18 ++++++++++++++++++ manifest.json | 3 ++- options.js | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/background.js b/background.js index d316dba..6f6e7f0 100644 --- a/background.js +++ b/background.js @@ -259,7 +259,8 @@ const blockedRegexes = { 'inquirer.com': /.+\.tinypass\.com\/.+/, 'spectator.co.uk': /.+\.tinypass\.com\/.+/, 'newcastleherald.com.au': /.+cdn-au\.piano\.io\/api\/tinypass.+\.js/, -'afr.com': /afr\.com\/assets\/vendorsReactRedux_client.+\.js/ +'afr.com': /afr\.com\/assets\/vendorsReactRedux_client.+\.js/, +'theglobeandmail.com': /theglobeandmail\.com\/pb\/resources\/scripts\/build\/chunk-bootstraps\/.+\.js/ }; const userAgentDesktop = "Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)" @@ -308,7 +309,7 @@ chrome.webRequest.onBeforeRequest.addListener(function(details) { return {cancel: true}; }, { - urls: ["*://*.theglobeandmail.com/*", "*://*.newstatesman.com/*"], + urls: ["*://*.newstatesman.com/*"], types: ["script"] }, ["blocking"] diff --git a/contentScript.js b/contentScript.js index 19a32fc..84fd12a 100644 --- a/contentScript.js +++ b/contentScript.js @@ -273,6 +273,24 @@ if (window.location.href.indexOf("afr.com") !== -1) { }); } +if (window.location.href.indexOf("theglobeandmail.com") !== -1) { + document.addEventListener('DOMContentLoaded', () => { + const lazy_image = document.querySelectorAll('.js-lazyimage'); + for (let i = 0; i < lazy_image.length; i++) { + lazy_image[i].classList.remove('js-lazyimage'); + } + 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("image/gif") !== -1) { + var data_src = hidden_image[i].getAttribute("data-src"); + if (data_src) + hidden_image[i].setAttribute('src', data_src); + } + } + }); +} + function removeDOMElement(...elements) { for (let element of elements) { if (element) element.remove(); diff --git a/manifest.json b/manifest.json index 5eaeaf7..ae5ecab 100644 --- a/manifest.json +++ b/manifest.json @@ -29,7 +29,8 @@ "*://*.techinasia.com/*", "*://*.newcastleherald.com.au/*", "*://*.thestar.com/*", - "*://*.afr.com/*" + "*://*.afr.com/*", + "*://*.theglobeandmail.com/*" ], "js": ["contentScript.js"] } diff --git a/options.js b/options.js index 186c637..1287c9b 100644 --- a/options.js +++ b/options.js @@ -71,7 +71,7 @@ var defaultSites = { 'The Boston Globe': 'bostonglobe.com', 'The Business Journals': 'bizjournals.com', 'The Diplomat': 'thediplomat.com', - 'The Globe and Mail (javascript disabled)': 'theglobeandmail.com', + 'The Globe and Mail': 'theglobeandmail.com', 'The Hindu': 'thehindu.com', 'The Japan Times': 'japantimes.co.jp', 'TheMarker': 'themarker.com',