I have a slight modification since the search bar that was added messes up the var games = document.getElementsByClassName("form"); array.
it uses jQuery to find and iterate since it's available.
I made some tweaks so that it will log the name of the game just added and will do all of them in order so it's easy to tell when it's done. NOTE: this does make it so you can't click anything on the page while it runs.
baseURL = window.location.protocol + "//" + window.location.host + location.pathname
$('.game_list').find('form[method=POST]').each(function(index,form){
var csrf_token = $(form).find('input[name=csrf_token]').val()
var game_id = $(form).find('input[name=game_id]').val()
try{
var xhr = new XMLHttpRequest();
xhr.open("POST", baseURL, false);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("csrf_token=" + csrf_token + "&game_id=" + game_id + "&action=claim");
} catch(error){
//console.log(error);
}
var game_title = $(form).parents('.game_row_data').find('.game_title').text()
console.log("added number",index+1, game_title)
})
Does anyone happen to know if newly added games are always added to the last page? If they aren't it might be tricky to find and add those among the ones you've already claimed.