Fix Globe and Mail (update)

Clear in-memory cache for Webrequest to work correctly (block or not block specific G&B-Javascript).
This commit is contained in:
magnolia1234 2020-01-11 21:16:10 +01:00 committed by GitHub
parent 95061e9ed4
commit 5058018836
2 changed files with 9 additions and 3 deletions

View file

@ -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 };
}

View file

@ -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);
}
}
});