Created
October 26, 2015 10:01
-
-
Save anonymous/ca9c3fd8146ee9fe1d81 to your computer and use it in GitHub Desktop.
Scrape HB keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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