// ==UserScript== // @name hb redeem // @namespace steam // @author 伟大鱼塘 // @description 激活hb key // @include https://www.humblebundle.com/home/keys // @match https://www.humblebundle.com/home/keys // @version 0.0.1 // @grant none // @downloadURL none // ==/UserScript== (function($) { let mulbtn = ''; let allbtn = ''; $('.unredeemed-keys-table').after(mulbtn, allbtn); function redeem() { let sessioninput = '

你的Session ID

' $('.unredeemed-keys-table tbody').prepend(sessioninput); let sessionid = null; let i = 0; let keys = []; $('#g_sessionID').on('input', function() { sessionid = $(this).val(); }); //单激活 { $.each($('#sessionidtr').nextAll(), (i, e) => { let btn = '' $(e).append(btn); }); $('.redeemsteamkey').on('click', function() { let key = $(this).parent().parent().find('.keyfield').attr('title'); if (!sessionid) { return alert('请输入你的Session ID!') } window.open(`https://store.steampowered.com/account/ajaxregisterkey/?product_key=${key}&sessionid=${sessionid}`); }); } //批量激活 { $('#sessionidtr').nextAll().on('click', function() { var that = $(this); if (!that.hasClass('act')) { that.css('background-color', '#DEF5E0').addClass('act'); } else { that.css('background-color', '#DCE0E7;').removeClass('act'); } }); $('#redeemselectedsteamkey').on('click', function() { keys = []; i = 1; $.each($('.act'), (i, e) => { let key = $(e).find('.keyfield').attr('title'); keys.push(key); }); if (!sessionid) { alert('请输入你的Session ID!'); } else if (keys.length) { window.open(`https://store.steampowered.com/account/ajaxregisterkey/?product_key=${keys[0]}&sessionid=${sessionid}`); circle(keys); } else { alert('请先选择要激活的游戏!'); } }); $('#redeemallsteamkey').on('click', function() { keys = []; i = 1; $.each($('.game-key-string'), (i, e) => { let key = $(e).find('.keyfield').attr('title'); keys.push(key); }); if (!sessionid) { alert('请输入你的Session ID!'); } else if (keys.length) { window.open(`https://store.steampowered.com/account/ajaxregisterkey/?product_key=${keys[0]}&sessionid=${sessionid}`); circle(keys); } }); } function circle() { setTimeout(function() { if (i > (keys.length - 1)) { alert('激活完成!'); return; }; window.open(`https://store.steampowered.com/account/ajaxregisterkey/?product_key=${keys[i]}&sessionid=${sessionid}`); i++; circle(); }, 15000); } } redeem(); $('.js-key-manager-holder').on('click', '.jump-to-page', function() { redeem(); }); })(jQuery);