Created
October 20, 2019 13:52
-
-
Save yuta0801/b381292531bdde8d5e54b373e2dad6a4 to your computer and use it in GitHub Desktop.
A Nipp to check Factorio server status
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
!(async () => { | |
document.getElementById('app').style.display = 'none' | |
document.write('読み込み中...') | |
const server = 'server_id' | |
const cors = 'https://cors-anywhere.herokuapp.com/' | |
const url = cors + 'https://multiplayer.factorio.com/get-game-details/' + server | |
const data = await fetch(url, { headers: { origin: 'any' } }).then(res => res.json()) | |
document.write([ | |
`${data.name}は現在オンラインです`, | |
'', | |
data.players ? [ | |
`現在、以下の${data.players.length}人が参加しています`, | |
data.players.join(', '), | |
] : '現在、誰も参加していません' | |
].flat().join('<br>')) | |
})().catch(error => document.write('エラーが発生しました:' + error.stack)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment