Forked from anonymous/scrape-humblebundle-keys.js
Last active
February 16, 2019 06:36
-
-
Save matchaxnb/26c368cd299588b8b045 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***'); | |
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); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@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!