Fix WaPo gdpr cookie-banner (by holding on to wp_gdpr cookie)

This commit is contained in:
magnolia1234 2019-10-25 15:00:08 +02:00 committed by GitHub
parent 547120a577
commit 450ddeeec1

View file

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