Skip to content

Instantly share code, notes, and snippets.

@Yiin
Last active Dec 11, 2018
Embed
What would you like to do?
// ==UserScript==
// @name Unnamed Script 760860
// @version 1
// @grant GM.xmlHttpRequest
// ==/UserScript==
(async () => {
const rows = [...document.querySelectorAll('#overview > tbody > tr')];
const promises = rows
.filter(el => el.querySelector('.iReport.iReport8'))
.map((el, index) => new Promise(resolve => {
setTimeout(() => {
console.log('parsing', `${index + 1}/${rows.length}`);
GM.xmlHttpRequest({
url: el.querySelector('.iReport + div > a').href,
method: 'GET',
onload(response) {
const parser = new DOMParser();
const page = parser.parseFromString(response.responseText, 'text/html');
const info = `${page.querySelector('.player').innerHTML.trim()} : ${el.querySelector('.dat').innerHTML.trim()}`;
resolve(info);
},
onerror() {
console.log('error');
resolve();
},
});
}, index * parseInt(Math.floor(Math.random() * 500) + 500));
}));
Promise.all(promises).then(data => data && console.log(data.join('\n')));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment