Skip to content

Instantly share code, notes, and snippets.

@matchaxnb
Forked from anonymous/scrape-humblebundle-keys.js
Last active February 16, 2019 06:36
Show Gist options
  • Save matchaxnb/26c368cd299588b8b045 to your computer and use it in GitHub Desktop.
Save matchaxnb/26c368cd299588b8b045 to your computer and use it in GitHub Desktop.
Scrape HB keys
// ==UserScript==
// @name Grab HB keys
// @namespace org.chloetigre.perso
// @description Grab game keys from a humble bundle page
// @include https://www.humblebundle.com/home/keys
// @version 1
// @grant none
// ==/UserScript==
var hbkeys = {
};
scrapekeys = function () {
lastpage = - 1;
//console.log('****scraper***');
output = "";
output += "Game name;Key\n";
$('div.pagination div.jump-to-page').each(function (i)
{
// console.log($(this));
if ($(this).data('index') > lastpage) {
lastpage = $(this).data('index');
}
});
// console.log('Last ' + lastpage);
i = 0;
while (i <= lastpage) {
$('div.jump-to-page[data-index="' + i + '"]').trigger('click');
$('div.keyfield').each(function (i)
{
parent = $(this).parents('tr').first();
// console.log('Parent ' + parent);
gamename = $(parent).find('td.game-name h4').first().attr('title');
output += gamename + ';' + $(this).attr('title') + "\n";
hbkeys[gamename] = $(this).attr('title');
});
i += 1;
}
document.hbkeys = hbkeys;
console.log(output);
};
$(document).ready(function () {
setTimeout(scrapekeys, 2000);
});
@zachjord
Copy link

zachjord commented Jan 1, 2018

@ChloeTigre could you please explain how this script is used? I have it installed with Greasemonkey, but from there I'm not sure what to do. Thanks!

@staberas
Copy link

Great script, saved me some time

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