Skip to content

Instantly share code, notes, and snippets.

@SharkyRawr
Created May 29, 2020 21:38
Show Gist options
  • Save SharkyRawr/6b12061eb08087b8a2c454a041a982f7 to your computer and use it in GitHub Desktop.
Save SharkyRawr/6b12061eb08087b8a2c454a041a982f7 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name HumbleBundle Exporter
// @namespace https://sharky.pw/
// @version 0.2
// @description Export lists of your HumbleBundle purchases, keys, etc.
// @author Sophie 'Sharky' Schumann
// @require http://code.jquery.com/jquery-1.9.1.min.js
// @match https://www.humblebundle.com/home/keys
// @match https://www.humblebundle.com/home/purchases
// @match https://www.humblebundle.com/home/library
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
(function() {
var bundles = {};
window.hb_scan = function() {
if ($('input[name="hide-redeemed"]').prop('checked') == false) {
$('input[name="hide-redeemed"]').click();
console.log('please retry command');
return;
}
$('table.unredeemed-keys-table tbody tr').each(function (i, div) {
var text = div.innerText;
var parts = text.split('\n');
var name = parts[0].trim();
var bundle = parts[1].trim();
var redeemable = parts[3].trim().replace('click to redeem on ', '');
if(typeof bundles[name] === 'undefined') {
bundles[name] = {
"name": name,
"bundle": bundle,
"redeemable": redeemable
};
}
});
window.bundles = bundles;
};
window.hb_export = function() {
var csv = "Name of Game, Contained in Bundle, Platform\n";
for(var i in bundles) {
var b = bundles[i];
csv += '"' + b.name + '","' + b.bundle + '","' + b.redeemable + '"\n';
}
console.log(csv);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment