From badfe3685a6b0ea5eb382f53a5ca5d6396a39056 Mon Sep 17 00:00:00 2001 From: Adam <36013816+iamadamdev@users.noreply.github.com> Date: Sun, 15 Oct 2023 13:41:19 -0700 Subject: [PATCH] Fix nytimes.com --- src/js/background.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/js/background.js b/src/js/background.js index 3a1eca7..ff5c28f 100755 --- a/src/js/background.js +++ b/src/js/background.js @@ -67,7 +67,8 @@ const allowCookies = [ 'zeit.de', 'expansion.com', 'dailytelegraph.com.au', - 'washingtonpost.com' + 'washingtonpost.com', + 'nytimes.com' ]; // Removes cookies after page load @@ -109,8 +110,7 @@ const removeCookies = [ 'wsj.com', 'medium.com', 'washingtonpost.com', - 'japantimes.co.jp', - 'nytimes.com' + 'japantimes.co.jp' ]; // Contains remove cookie sites above plus any custom sites @@ -156,7 +156,8 @@ const useGoogleBotSites = [ 'df.cl', 'ft.com', 'wired.com', - 'zeit.de' + 'zeit.de', + 'nytimes.com' ]; // Override User-Agent with Bingbot @@ -526,6 +527,24 @@ extensionApi.webRequest.onCompleted.addListener(function (details) { urls: [''] }); +// nytimes.com fix +extensionApi.webRequest.onHeadersReceived.addListener(function (details) { + if (!isSiteEnabled(details)) { + return; + } + let headers = details.responseHeaders; + headers = headers.map(function (header) { + if (header.name === 'x-frame-options') { header.value = 'SAMEORIGIN'; } + return header; + }); + return { + responseHeaders: headers + }; +}, { + urls: ['*://*.nytimes.com/*'] +}, +['blocking', 'responseHeaders']); + // Google Analytics to anonymously track DAU (Chrome only) function initGA () { (function (i, s, o, g, r, a, m) {