Unverified Commit 177b84dc authored by Aral Balkan's avatar Aral Balkan
Browse files

Add colour highlighting to unhandled trackers in stats list.

parent 09522efb
......@@ -19,6 +19,11 @@ ContentIndex = require './ContentIndex'
_ = (m) -> console.log m
kHighlightStatusAwareOf = " 🔎"
kHighlightStatusUnawareOf = " ⬅"
kHighlightStatusBlocked = " ⛔"
kHighlightStatusCookiesBlocked = " 🍪"
args = (require 'minimist') process.argv.slice(2), {boolean: true}
# If not called with any commandline arguments, assume all.
......@@ -48,17 +53,24 @@ Statistics.generateIfNecessary(args.all || args.google).then (statistics) ->
# Is this a tracker that we’re aware of?
# (In other words, is there an entry for it under /trackers in the database?)
trackerBlockStatus = if (entry.domain in contentIndex.trackers) then " 🔎" else " ⚠"
trackerBlockStatus = if (entry.domain in contentIndex.trackers) then kHighlightStatusAwareOf else kHighlightStatusUnawareOf
# Is this a tracker that we block?
trackerBlockStatus = if (entry.domain in contentIndex.trackersBlocked) then " ⛔" else trackerBlockStatus
trackerBlockStatus = if (entry.domain in contentIndex.trackersBlocked) then kHighlightStatusBlocked else trackerBlockStatus
# Note: not-blocked trackers are still trackers that we are handling in some way
# but not blocking outright (so we are aware of them). We can extrapolate that this
# means that we’re blocking cookies.
trackerBlockStatus = if (entry.domain in contentIndex.trackersNotBlocked) then " 🍪" else trackerBlockStatus
trackerBlockStatus = if (entry.domain in contentIndex.trackersNotBlocked) then kHighlightStatusCookiesBlocked else trackerBlockStatus
# Highlight unhandled domains so they stand out even more
highlightStart = ""
highlightEnd = ""
if trackerBlockStatus is kHighlightStatusUnawareOf
highlightStart = "\u001b[33m"
highlightEnd = "\u001b[0m"
_ "#{i+1}. #{entry.domain} (#{entry.count} sites – on #{(entry.count * 100 / statistics.totalNumberOfSites).toFixed(1)}% of sites)#{trackerBlockStatus}"
_ "#{i+1}. #{highlightStart}#{entry.domain}#{highlightEnd} (#{entry.count} sites – on #{(entry.count * 100 / statistics.totalNumberOfSites).toFixed(1)}% of sites)#{trackerBlockStatus}"
printCount++
if args.count? and printCount is args.count then break
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment