From 5058018836ce748555371ebe42621ee477d12982 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Sat, 11 Jan 2020 21:16:10 +0100 Subject: [PATCH] Fix Globe and Mail (update) Clear in-memory cache for Webrequest to work correctly (block or not block specific G&B-Javascript). --- background.js | 7 +++++-- contentScript.js | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/background.js b/background.js index 9580071..21ab378 100644 --- a/background.js +++ b/background.js @@ -310,8 +310,8 @@ browser.runtime.onInstalled.addListener(function(details) { }); // Disable javascript for these sites -chrome.webRequest.onBeforeRequest.addListener(function(details) { - if (!isSiteEnabled(details) || details.url.indexOf("mod=rsswn") !== -1) { +browser.webRequest.onBeforeRequest.addListener(function(details) { + if (!isSiteEnabled(details)) { return; } return {cancel: true}; @@ -342,6 +342,9 @@ browser.webRequest.onBeforeSendHeaders.addListener(function(details) { if (details.url.indexOf('meter.bostonglobe.com/js/') !== -1 && (header_referer === 'https://www.bostonglobe.com/' || header_referer.indexOf('/?p1=BGHeader_') !== -1 || header_referer.indexOf('/?p1=BGMenu_') !== -1)) { break; + } else if (header_referer.indexOf('theglobeandmail.com') !== -1 && !(header_referer.indexOf('/article-') !== -1)) { + browser.webRequest.handlerBehaviorChanged(function () {}); + break; } return { cancel: true }; } diff --git a/contentScript.js b/contentScript.js index 3414835..0ee5d52 100644 --- a/contentScript.js +++ b/contentScript.js @@ -272,10 +272,13 @@ if (window.location.href.indexOf("theglobeandmail.com") !== -1) { 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) { + if (src.indexOf("data:image/gif") !== -1) { var data_src = hidden_image[i].getAttribute("data-src"); if (data_src) hidden_image[i].setAttribute('src', data_src); + var data_bg = hidden_image[i].getAttribute("data-bg"); + if (data_bg) + hidden_image[i].setAttribute('src', data_bg); } } });