-
Notifications
You must be signed in to change notification settings - Fork 0
Event data extraction scripts
Thai Pangsakulyanont edited this page Aug 18, 2020
·
10 revisions
(() => {
const asNumber = x => {
const v = +x
return v === 0 ? 0 : (v || null)
}
const entries = [...document.querySelectorAll('[class^="BmsListItem_list_item"]')]
.map(el => {
Array.from(el.querySelectorAll('[class*="BmsListItem_hidden_artists"], [class*="BmsListItem_subartist"]')).forEach(el => el.remove())
return {
entryId: el.querySelector('[class*="BmsListItem_no"]').textContent.trim(),
url: el.querySelector('a').href,
title: el.querySelector('[class*="BmsListItem_title"]').textContent.trim(),
artist: el.querySelector('[class*="BmsListItem_artist"]').textContent.trim(),
genre: el.querySelector('[class*="BmsListItem_genre"]').textContent.trim(),
// team: el.querySelector('.team').textContent.trim(),
impressions: asNumber(el.querySelector('[class*="BmsListItem_impression_count"]').textContent.trim()),
total: asNumber(el.querySelector('[class*="BmsListItem_total_points"]').textContent.trim()),
average: asNumber(el.querySelector('[class*="BmsListItem_average_points"]').textContent.trim()),
}
})
copy(entries)
console.log('Copied ' + entries.length + ' entries')
})()
(() => {
const asNumber = x => {
const v = +x
return v === 0 ? 0 : (v || null)
}
const imageText = el => {
const img = el.querySelector('img')
return img ? img.title : el.textContent.trim()
}
const entries = [...document.querySelectorAll('tr>.title')].map(el => el.parentNode)
.map(el => {
return {
entryId: el.querySelector('.id').textContent.trim(),
url: el.querySelector('.title>a').href,
title: el.querySelector('.title>a').textContent.trim(),
artist: el.querySelector('.name').textContent.trim(),
genre: el.querySelector('.genre').textContent.trim(),
team: imageText(el.closest('.entrylist').previousSibling),
impressions: asNumber(el.querySelector('.impre').textContent.trim()),
total: asNumber(el.querySelector('.total').textContent.trim()),
average: asNumber(el.querySelector('.average').textContent.trim()),
}
})
copy({ $set: { entries } })
console.log('Copied ' + entries.length + ' entries')
})()
(() => {
const api = $('#list').dataTable().api()
const asNumber = x => {
const v = +x
return v === 0 ? 0 : (v || null)
}
// Show all columns
api.columns().visible(true)
const entries = api.rows().nodes().toArray().map(row => {
return {
entryId: row.cells[0].textContent.trim(),
url: row.cells[0].querySelector('a').href,
team: row.cells[1].textContent.trim(),
artist: row.cells[2].textContent.trim(),
genre: row.cells[3].textContent.trim(),
title: row.cells[4].textContent.trim(),
impressions: asNumber(row.cells[5].textContent.trim()),
total: asNumber(row.cells[6].textContent.trim()),
median: asNumber(row.cells[7].textContent.trim()),
}
})
copy({ $set: { entries } })
console.log('Copied ' + entries.length + ' entries')
})()
(() => {
const asNumber = x => {
const v = +x
return v === 0 ? 0 : (v || null)
}
const entries = [...document.querySelectorAll('.pabat_readform_list_box')]
.map(el => {
const m = el.querySelector('.pabat_readform_list_title_score_n_appeal')
.textContent
.replace(/\s+/g, ' ')
.match(/impre : (\S+) \| median : (\S+) \| total : (\S+)/)
return {
entryId: el.querySelector('.pabat_readform_list_title_name a').href.match(/\bnum=(\d+)/)[1],
url: el.querySelector('.pabat_readform_list_title_name a').href,
title: el.querySelector('.pabat_readform_list_title_name').textContent.trim(),
artist: el.querySelector('.pabat_readform_list_artist').textContent.trim(),
genre: el.querySelector('.pabat_readform_list_genre').textContent.trim(),
impressions: asNumber(m && m[1]),
total: asNumber(m && m[3]),
median: asNumber(m && m[2]),
}
})
copy({ $set: { entries } })
console.log('Copied ' + entries.length + ' entries')
})()
(() => {
const asNumber = x => {
const v = +x
return v === 0 ? 0 : (v || null)
}
const entries = [...document.querySelectorAll('.title_borderdiv')]
.map(el => {
const m = el.querySelector('tr:nth-of-type(4)>td')
.textContent
.replace(/\s+/g, ' ')
.match(/impre : (\S+) \| median : (\S+) \| total : (\S+)/)
return {
entryId: el.querySelector('tr[bgcolor="#ffffff"]>td[height="24"][colspan="4"] a').href.match(/\bnum=(\d+)/)[1],
url: el.querySelector('tr[bgcolor="#ffffff"]>td[height="24"][colspan="4"] a').href,
title: el.querySelector('tr[bgcolor="#ffffff"]>td[height="24"][colspan="4"] a').textContent.trim(),
artist: el.querySelector('tr[bgcolor="#9fdbec"]>td[width="284"]').textContent.trim(),
genre: el.querySelector('tr[bgcolor="#ffffff"]>td[height="18"][colspan="3"]').textContent.trim(),
impressions: asNumber(m && m[1]),
total: asNumber(m && m[3]),
median: asNumber(m && m[2]),
}
})
copy({ $set: { entries } })
console.log('Copied ' + entries.length + ' entries')
})()
(() => {
const asNumber = x => {
const v = +x
return v === 0 ? 0 : (v || null)
}
const entries = [...document.querySelectorAll('td[width="435"]>table[width="430"]')]
.map(el => {
const m = el.querySelector('tr:nth-of-type(4)>td')
.textContent
.replace(/\s+/g, ' ')
.match(/impre : (\S+) \| median : (\S+) \| total : (\S+)/)
return {
entryId: el.querySelector('tr:nth-of-type(3) a').href.match(/\bnum=(\d+)/)[1],
url: el.querySelector('tr:nth-of-type(3) a').href,
title: el.querySelector('tr:nth-of-type(3) strong a').textContent.trim(),
artist: el.querySelector('tr:nth-of-type(1)>td[colspan="3"]').textContent.trim(),
genre: el.querySelector('tr:nth-of-type(2)>td').textContent.trim(),
impressions: asNumber(m && m[1]),
total: asNumber(m && m[3]),
median: asNumber(m && m[2]),
}
})
copy({ $set: { entries } })
console.log('Copied ' + entries.length + ' entries')
})()