From 450ddeeec1484fd05f4385ecaf6ab22a10824361 Mon Sep 17 00:00:00 2001 From: magnolia1234 <7676006-magnolia1234@users.noreply.gitlab.com> Date: Fri, 25 Oct 2019 15:00:08 +0200 Subject: [PATCH] Fix WaPo gdpr cookie-banner (by holding on to wp_gdpr cookie) --- background.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/background.js b/background.js index e6bf9fe..bcb58a8 100644 --- a/background.js +++ b/background.js @@ -156,6 +156,18 @@ const remove_cookies = [ 'wsj.com', ] +// select specific cookie(s) to hold from remove_cookies domains +const remove_cookies_select_hold = { + '.nrc.nl': ['nmt_closed_cookiebar'], + '.washingtonpost.com': ['wp_gdpr'], + '.wsj.com': ['wsjregion'] +} + +// select only specific cookie(s) to drop from remove_cookies domains +const remove_cookies_select_drop = { + 'www.nrc.nl': ['counter'] +} + // Override User-Agent with Googlebot const use_google_bot = [ 'barrons.com', @@ -372,6 +384,17 @@ browser.webRequest.onCompleted.addListener(function(details) { if (cookies[i].firstPartyDomain !== undefined) { cookie.firstPartyDomain = cookies[i].firstPartyDomain; } + + var cookie_domain = cookies[i].domain; + // hold specific cookie(s) from remove_cookies domains + if ((cookie_domain in remove_cookies_select_hold) && remove_cookies_select_hold[cookie_domain].includes(cookies[i].name)){ + continue; // don't remove specific cookie + } + // drop only specific cookie(s) from remove_cookies domains + if ((cookie_domain in remove_cookies_select_drop) && !(remove_cookies_select_drop[cookie_domain].includes(cookies[i].name))){ + continue; // only remove specific cookie + } + browser.cookies.remove(cookie); } });