Skip to content

Instantly share code, notes, and snippets.

Created October 26, 2015 10:01
Show Gist options
  • Save anonymous/ca9c3fd8146ee9fe1d81 to your computer and use it in GitHub Desktop.
Save anonymous/ca9c3fd8146ee9fe1d81 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***')
$('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');
console.log('Gamename ' + gamename);
hbkeys[gamename] = $(this).attr('title');
});
i += 1
}
document.hbkeys = hbkeys;
}
$(document).ready(function () {
setTimeout(scrapekeys, 2000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment