Greasy Fork

Greasy Fork is available in English.

hb redeem

激活hb key

当前为 2017-08-31 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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 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');
			}
		});
		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);
		$('#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);
	}

})(jQuery);