Add exception for economist.com graphics rendering script (#631)

This commit is contained in:
Francesco Truzzi 2020-05-15 04:03:43 +02:00 committed by GitHub
parent 6e50680a93
commit 3692cb8bee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -173,6 +173,11 @@ const blockedRegexes = {
'thewrap.com': /thewrap\.com\/.+\/wallkit\.js/
};
// Allowed external scripts
const allowedRegexes = {
'economist.com': /infographics.economist.com\/utils\/ai2html-resizer.*\.js/
};
const userAgentDesktop = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';
const userAgentMobile = 'Chrome/41.0.2272.96 Mobile Safari/537.36 (compatible ; Googlebot/2.1 ; +http://www.google.com/bot.html)';
@ -231,6 +236,12 @@ extensionApi.webRequest.onBeforeRequest.addListener(function (details) {
if (!isSiteEnabled(details) && !enabledSites.includes('generalpaywallbypass')) {
return;
}
// Don't block allowed scripts
for (const domain in allowedRegexes) {
if (isSameDomain(details.url, domain) && details.url.match(allowedRegexes[domain])) {
return;
}
}
return { cancel: true };
},
{