Skip to content

Instantly share code, notes, and snippets.

View FTAndy's full-sized avatar

Andy Qin FTAndy

View GitHub Profile
@FTAndy
FTAndy / steam-game-hours.js
Created September 29, 2023 02:37
Steam total game hours caculation
const elements = Array.from(document.querySelectorAll('.gameslistitems_Hours_26nl3'))
const hours = s.map(d => d.innerText).filter(c => c.include('hours')).map(o => parseInt(/(?!\n)(.+) hours/.exec(o)[1].replace(',', '')) ).reduce((a, b) => a + b ,0)
console.log(hours)
@FTAndy
FTAndy / synchronize-array-promises.js
Created November 2, 2016 15:16
Promise synchronize array promises
let results = []
dataArray.reduce((prePromise, data) => {
return prePromise.then(() => {
return dosomethingWithData(data)
.then((result) => {
results.push(result)
})
})
}, Promise.resolve())