hb redeem

激活hb key

目前為 2017-08-31 提交的版本,檢視 最新版本

// ==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
// ==/UserScript==

(function($) {

	let mulbtn = '<button id="redeemselectedsteamkey" style="border:none;display:block;color:#fff;background:rgba(155, 89, 182,0.8);text-align:center;padding:10px;width:60%;margin:auto;margin-top:20px;border-radius:10px;">激活选中游戏</button>';
	let allbtn = '<button id="redeemallsteamkey" style="border:none;display:block;color:#fff;background:rgba(52, 73, 94,0.75);text-align:center;padding:10px;width:60%;margin:auto;margin-top:20px;margin-bottom:20px;border-radius:10px;">激活全部游戏</button>';
	$('.unredeemed-keys-table').after(mulbtn, allbtn);

	function redeem() {
		let sessioninput = '<tr id="sessionidtr"><td class="platform"><i class="hb hb-key hb-steam" title="Steam"></i></td><td><h4 title="Dead Age">你的Session ID</h4></td><td class="js-redeemer-cell redeemer-cell"><div class="key-redeemer"><div class="container"><div class="keyfield redeemed"><input id="g_sessionID" type="text" style="width:100%;background: #E9EEE4;border:none;color: #7A981C;font-size:16px;text-align:center;"></div></div></div></td><td></td></tr>'
		$('.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 = '<td style="padding:0;text-align:center;"><button class="redeemsteamkey" style="padding:8px 16px;border:1px solid #7A981C;color:#7A981C;background: #E9EEE4;">激活</button></td>'
				$(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);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址