Unverified Commit 09522efb authored by Aral Balkan's avatar Aral Balkan
Browse files

Update stats to flag tracker support state.

parent aecacfd6
......@@ -15,6 +15,7 @@
################################################################################
Statistics = require './Statistics'
ContentIndex = require './ContentIndex'
_ = (m) -> console.log m
......@@ -25,49 +26,67 @@ if (not args.all) and (not args.trackers) and (not args.sites)
args.all = true
Statistics.generateIfNecessary(args.all || args.google).then (statistics) ->
if args.all or args.trackers
_ "\nTrackers by popularity:\n"
startPrinting=true
printCount=0
if args.start? then startPrinting = false
for i in [0...statistics.sitesPerTrackerDescendingOrder.length]
entry = statistics.sitesPerTrackerDescendingOrder[i]
# Generate the content index so we can flag which trackers are
# already handled and which are not.
ContentIndex.generateIfNecessary().then (contentIndex) ->
if not startPrinting
if entry.domain is args.start
startPrinting=true
if args.all or args.trackers
_ "\nTrackers by popularity:\n"
if startPrinting
_ "#{i+1}. #{entry.domain} (#{entry.count} sites – on #{(entry.count * 100 / statistics.totalNumberOfSites).toFixed(1)}% of sites)"
printCount++
if args.count? and printCount is args.count then break
startPrinting=true
printCount=0
if args.start? then startPrinting = false
for i in [0...statistics.sitesPerTrackerDescendingOrder.length]
entry = statistics.sitesPerTrackerDescendingOrder[i]
if args.all or args.sites
_ "\nSites by most trackers:\n"
if not startPrinting
if entry.domain is args.start
startPrinting=true
startPrinting=true
printCount=0
if args.start? then startPrinting = false
for i in [0...statistics.trackersPerSiteDescendingOrder.length]
entry = statistics.trackersPerSiteDescendingOrder[i]
if startPrinting
if not startPrinting
if entry.domain is args.start
startPrinting=true
# 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 " ⚠"
if startPrinting
_ "#{i+1}. #{entry.domain}: (#{entry.count} trackers)"
printCount++
if args.count? and printCount is args.count then break
# Is this a tracker that we block?
trackerBlockStatus = if (entry.domain in contentIndex.trackersBlocked) then " ⛔" else trackerBlockStatus
if args.all or args.gooogle
_ "\nGoogle trackers:\n"
# 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
googleTrackerIndex = 0
_ "#{i+1}. #{entry.domain} (#{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
for googleTracker in (Array.from statistics.googleDomains)
googleTrackerIndex++
_ "#{googleTrackerIndex}: #{googleTracker}"
if args.all or args.sites
_ "\nSites by most trackers:\n"
_ ""
\ No newline at end of file
startPrinting=true
printCount=0
if args.start? then startPrinting = false
for i in [0...statistics.trackersPerSiteDescendingOrder.length]
entry = statistics.trackersPerSiteDescendingOrder[i]
if not startPrinting
if entry.domain is args.start
startPrinting=true
if startPrinting
_ "#{i+1}. #{entry.domain}: (#{entry.count} trackers)"
printCount++
if args.count? and printCount is args.count then break
if args.all or args.gooogle
_ "\nGoogle trackers:\n"
googleTrackerIndex = 0
for googleTracker in (Array.from statistics.googleDomains)
googleTrackerIndex++
_ "#{googleTrackerIndex}: #{googleTracker}"
_ ""
\ No newline at end of file
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