-
-
Save grambas/fd0b32f3a1b399f0d617c0d0fdd2d100 to your computer and use it in GitHub Desktop.
[Userscripts]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Unnamed Script 760860 | |
// @version 1 | |
// @grant GM.xmlHttpRequest | |
// get all players who sent reinforcement | |
// ==/UserScript== | |
(async () => { | |
const rows = [...document.querySelectorAll('#overview > tbody > tr')]; | |
const thisPlayer = document.getElementsByClassName('playerName')[0].childNodes[3].innerHTML; | |
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()}`; | |
let info = ""; | |
if( thisPlayer != page.querySelector('.player').innerHTML.trim() ){ | |
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