This repository has been archived by the owner on Nov 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathdump.js
53 lines (40 loc) · 1.46 KB
/
dump.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
var fs = require('fs')
var getPublisher = require('./index').getPublisher
var Synopsis = require('./index').Synopsis
var underscore = require('underscore')
var sites = JSON.parse(fs.readFileSync(process.env.HOME + '/Library/Application Support/Brave/session-store-1')).sites
var locations = {}
var publishers = {}
var synopsis = new Synopsis()
sites.forEach(function (site) {
var markup, publisher
var location = site.location
if (location) synopsis.addVisit(location, Math.random() * 300 * 1000)
if ((!location) || (locations[location])) return
locations[location] = site
try {
if (location.indexOf('https://www.youtube.com/watch') !== -1) {
try { markup = require('knodeo-http-sync').httpSync.get(location).toString() } catch (err) {}
}
publisher = getPublisher(location, markup)
if (!publisher) return
if (!publishers[publisher]) publishers[publisher] = []
publishers[publisher].push(location)
} catch (err) {
console.log(location + ': ' + err.toString())
}
})
var keys = underscore.keys(publishers).sort()
console.log('\npublishers:')
console.log(keys)
var mappings = {}
keys.forEach(function (publisher) {
mappings[publisher] = publishers[publisher]
})
console.log('\nmappings:')
console.log(JSON.stringify(mappings, null, 2))
console.log('\ntopN:')
console.log(JSON.stringify(synopsis.topN(), null, 2))
console.log('\nallN:')
console.log(JSON.stringify(synopsis.allN(), null, 2))
console.log('\nwinner: ' + synopsis.winner())