Skip to content

Instantly share code, notes, and snippets.

@martymcguire
Last active May 24, 2023 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martymcguire/e8f040cb9f2f5b9b09ed71a7b415c790 to your computer and use it in GitHub Desktop.
Save martymcguire/e8f040cb9f2f5b9b09ed71a7b415c790 to your computer and use it in GitHub Desktop.
itch.io bundle bookmarklet

A little bookmarklet for use on itch.io bundle pages. Grabs the metadata for all items on the page and converts it to a partial* JSON string.

(* partial because items are comma-separated, but there's no leading [ or trailing ] because I wanted to be able to quickly copy and paste multiple pages worth of data into a single .json file)

Motivation and other details here: https://martymcgui.re/2023/05/23/scratching-an-itch-dot-io/

javascript:(function()%7Bnavigator.clipboard.writeText(Array.from(document.querySelectorAll('.game_row')).map((row)%3D%3E%7Breturn%20JSON.stringify(%7B'name'%3Arow.querySelector('.game_title%20a').textContent%2C'url'%3Arow.querySelector('.game_title%20a').href%2C'blurb'%3Arow.querySelector('.game_short_text')%3F.textContent%2C'img'%3Arow.querySelector('.game_thumb').attributes%5B'data-background_image'%5D%3F.value%2C'author'%3A%7B'name'%3Arow.querySelector('.game_author%20a').textContent%2C'url'%3Arow.querySelector('.game_author%20a').href%7D%2C'files'%3Arow.querySelector('.file_count')%3F.textContent%2C'platforms'%3AArray.from(row.querySelectorAll('.meta_row%20%3E%20span%5Bclass%5E%3D%22icon%22%5D')%7C%7C%5B%5D).map((pf)%3D%3Epf.attributes%3Fpf.attributes%5B'title'%5D.value%3A'')%7D)%7D).join(%22%2C%5Cn%22))%3B%7D)()
navigator
.clipboard
.writeText(Array.from(document.querySelectorAll('.game_row')).map((row) => {
return JSON.stringify({
'name': row
.querySelector('.game_title a')
.textContent,
'url': row
.querySelector('.game_title a')
.href,
'blurb': row.querySelector('.game_short_text')
?.textContent,
'img': row
.querySelector('.game_thumb')
.attributes['data-background_image']
?.value,
'author': {
'name': row
.querySelector('.game_author a')
.textContent,
'url': row
.querySelector('.game_author a')
.href
},
'files': row.querySelector('.file_count')
?.textContent,
'platforms': Array.from(row.querySelectorAll('.meta_row > span[class^="icon"]') || []).map((pf) => pf.attributes
? pf.attributes['title'].value
: '')
})
}).join(",\n"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment