From 44429dceb889778f31506cf5f535d38f49c5e33b Mon Sep 17 00:00:00 2001 From: Kipras Melnikovas Date: Sat, 16 Jan 2021 20:13:53 +0200 Subject: [PATCH] feat: allow blacklisting domains fixes https://github.com/mikecao/umami/issues/429 Signed-off-by: Kipras Melnikovas --- tracker/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tracker/index.js b/tracker/index.js index fc8458b0..683796fe 100644 --- a/tracker/index.js +++ b/tracker/index.js @@ -23,12 +23,25 @@ import { removeTrailingSlash } from '../lib/url'; const dnt = attr('data-do-not-track'); const useCache = attr('data-cache'); const domains = attr('data-domains'); + const domainBlacklist = attr('data-domains-blacklist'); + /** + * blacklist has higher importance than whitelist, + * + * i.e., if an item is both whitelisted and blacklisted, + * it will be blacklisted. + * + */ const disableTracking = localStorage.getItem('umami.disabled') || (dnt && doNotTrack()) || (domains && !domains + .split(',') + .map(n => n.trim()) + .includes(hostname)) || + (domainBlacklist && + domainBlacklist .split(',') .map(n => n.trim()) .includes(hostname));