Skip to content

Instantly share code, notes, and snippets.

@yuta0801
Created October 20, 2019 13:52
Show Gist options
  • Save yuta0801/b381292531bdde8d5e54b373e2dad6a4 to your computer and use it in GitHub Desktop.
Save yuta0801/b381292531bdde8d5e54b373e2dad6a4 to your computer and use it in GitHub Desktop.
A Nipp to check Factorio server status
!(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