Skip to content

Instantly share code, notes, and snippets.

@kelsin
Last active April 8, 2025 22:38
Show Gist options
  • Save kelsin/2416b7f272d5bf1c114f6ab764ca7ac7 to your computer and use it in GitHub Desktop.
Save kelsin/2416b7f272d5bf1c114f6ab764ca7ac7 to your computer and use it in GitHub Desktop.
18xx.games go to next game
javascript: (() => {
if (!(window.location.href.match('https://18xx.games'))) {
window.location.href = `https://18xx.games`;
}
const playerId = document.getElementById('nav').children[1].href.match(/profile\/(\d+)/)[1];
fetch("/api/game")
.then(response => response.json())
.then(response => response.games)
.then(games => games.find(x => x.acting.includes(parseInt(playerId))))
.then(game => {
if (game) {
window.location.href = `/game/${game.id}`;
} else {
window.location.href = `/`;
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment