Skip to content

Instantly share code, notes, and snippets.

@Yiin
Last active December 11, 2018 16:54
Show Gist options
  • Save Yiin/1cbc08e680674a708287979a3a62bdef to your computer and use it in GitHub Desktop.
Save Yiin/1cbc08e680674a708287979a3a62bdef to your computer and use it in GitHub Desktop.
// ==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