Skip to content

Instantly share code, notes, and snippets.

@joncloud
Created February 19, 2022 22:37
Show Gist options
  • Save joncloud/437a889600d8cc6135ce9ced548b4e26 to your computer and use it in GitHub Desktop.
Save joncloud/437a889600d8cc6135ce9ced548b4e26 to your computer and use it in GitHub Desktop.
Claim all downloads on an itch.io bundle page

itch.io Bundle Claim

Description

This is a simple script, which claims all of the bundle downloads for your account so you don't have to manually click the 'Download' button on each item.

Directions

  1. Login to itch.io
  2. Browse to the bundle page
  3. Open the developer console (typically F12, but depends on browser)
    • Choose the "Console" tab
  4. Run the script
    • Copy the entire contents of script.js
    • Paste it into the console
    • Press enter
    • Wait for the console message of 'finished' to appear, with the count of downloads claimed
  5. Go to the next bundle page, and run again
(async () => {
// Find all buttons on the page that have the claim value, e.g., the
// button you'd normally click to claim the download.
const buttons = Array.from(document.getElementsByTagName('button'))
.filter(btn => btn.value === 'claim');
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
const claim = async (btn) => {
// jQuery is still useful!
const form = $(btn.parentElement).serialize()
+ '&action=claim';
// Send an HTTP POST message to the current URL in the browser.
await fetch(window.location, {
method: 'POST',
credentials: 'include',
headers: {
// Mimic all of the headers that are sent normally when you click.
['Accept']: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
['Accept-Language']: 'en-US,en;q=0.5',
['Accept-Encoding']: 'gzip, deflate, br',
['Content-Type']: 'application/x-www-form-urlencoded',
['Upgrade-Insecure-Requests']: '1',
['Sec-Fetch-Dest']: 'document',
['Sec-Fetch-Mode']: 'navigate',
['Sec-Fetch-Site']: 'same-origin',
['Sec-Fetch-User']: '?1',
},
body: form,
redirect: 'manual'
});
};
// Claim each of the downloads
for (const button of buttons) {
await claim(button);
// Be kind to the itch.io servers
await sleep(2000);
}
console.log('finished', { count: buttons.length });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment