-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-aim-list.js
31 lines (26 loc) · 885 Bytes
/
get-aim-list.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
els = document.getElementsByClassName('aimlist-item')
const items = []
const itemHash = {}
let intervalId
const grabItems = () => {
for (let i = 0; i < els.length; ++i) {
const { id, title, textContent, tagName } = els[i]
if (itemHash[id]) continue
let item
if (tagName === 'H2') {
item = { id, title, type: 'group' }
} else if (tagName === 'DIV') {
item = { id, username: title, displayName: textContent, type: 'buddy' }
} else {
console.warn(`Warning! Unknown tagname encountered: (id: ${id}, tagName: ${tagName})`)
}
items.push(item)
itemHash[id] = true
}
}
const done = () => {
clearInterval(intevalId)
console.log(`Done! ${items.length} items saved!`)
}
intervalId = setInterval(grabItems, 100)
console.log('Ready to log, start scrolling slowly now')