Skip to content

Instantly share code, notes, and snippets.

@cold-logic
Last active December 6, 2019 22:51
Show Gist options
  • Save cold-logic/c76e307922be71dea5c0453934a4807b to your computer and use it in GitHub Desktop.
Save cold-logic/c76e307922be71dea5c0453934a4807b to your computer and use it in GitHub Desktop.
Copies a list of humble bundle games into your clipboard for inventory managment
/*
* Copies a list of humble bundle games into your clipboard for inventory managment
* Designed for the receipt/download pages:
* https://www.humblebundle.com/downloads?key={key}
*/
{
console.clear()
// Feel free to customize these tags as you wish
const tags = ['#Humble'].join(' ')
// DOM query selectors
const redeemableTitles = Array.from(document.querySelectorAll('.key-redeemer h4'))
const downloadableTitles = Array.from(document.querySelectorAll('.gameinfo .title'))
// Array reducer, reduces titles into one newline delimited string
const titlesReducer = (pre, cursor, idx) => `${pre}${(idx === 0) ? '' : `\n`}${cursor} ${tags}`
let output = [...redeemableTitles, ...downloadableTitles]
.map(title => title.innerText)
.reduce(titlesReducer, '')
// Fn to pipe output to the clipboard and the console
const copyAndLog = output => {
[copy, console.log].reduce((a, b) => arg => a(arg) || b(arg))(output)
}
copyAndLog(output)
}
@sgtpepper901
Copy link

Hey, I'm a noob, how do I use this?

@cold-logic
Copy link
Author

@sgtpepper901 - To use this; You open up the Humble bundle purchase screen, and then paste this code into the JavaScript console in your browser's dev tools. You can access the dev tools by right clicking anywhere in the page and clicking the "Inspect" menu item.

This code finds and collects all of the game names into a list. Then it copies the list into your clipboard for pasting into services like Workflowy or Dynalist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment