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