ig redeem

激活ig key

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        ig redeem
// @namespace   steam
// @author      伟大鱼塘
// @description 激活ig key
// @include     https://www.indiegala.com/gift?*
// @match       https://www.indiegala.com/gift?*
// @version     0.0.1
// @grant       none
// ==/UserScript==

(function($) {
	let sessioninput = '<div style="height: 61px;margin:0 25px;"><div class="span-title"><h4 class="title_game"><a target="_blank" class="game-steam-url"><b>你的Session ID</b></a></h4></div><div class="span-key steam-btn"><div class="option"><input id="g_sessionID" class="input-block-level margin text_align_center keys" type="text" value="" style="margin:0 ;"></div></div></div>'
	$('#steam-key-games').after(sessioninput);
	$('.game-key-string').css('height', '115px');
	let sessionid = null;
	let i = 0;
	let keys = [];
	$('#g_sessionID').on('input', function() {
		sessionid = $(this).val();
	});

	//单激活
	function s_redeem() {
		$.each($('.game-key-string'), (i, e) => {
			let btn = '<button class="redeemsteamkey input-block-level margin text_align_center keys" style="margin-top:20px;">激活</button>'
			$(e).find('.span-key>div').append(btn);
		});
		$('.redeemsteamkey').on('click', function() {
			let key = $(this).prev().val();
			window.open('https://store.steampowered.com/account/ajaxregisterkey/?product_key=' + key + '&sessionid=' + sessionid)
		});
	}

	//批量激活
	function m_redeem() {
		$('.game-key-string').on('click', function() {
			var that = $(this);
			if (!that.hasClass('act')) {
				that.css('background-color', 'rgba(89, 204, 103,.2)').addClass('act');
			} else {
				that.attr('style', 'height: 115px;').removeClass('act');
			}
		});
		let mulbtn = '<button id="redeemselectedsteamkey" style="display:block;color:#fff;background:rgba(155, 89, 182,0.8);text-align:center;padding:10px;width:60%;margin:auto;border-radius:10px;">激活选中游戏</button>';
		let allbtn = '<button id="redeemallsteamkey" style="display:block;color:#fff;background:rgba(52, 73, 94,0.75);text-align:center;padding:10px;width:60%;margin:auto;margin-top:20px;border-radius:10px;">激活全部游戏</button>';
		$('#steam-key').append(mulbtn, allbtn);
		$('#redeemselectedsteamkey').on('click', function() {
			keys = [];
			i = 0;
			$.each($('.act'), (i, e) => {
				let key = $(e).find('input').val();
				keys.push(key);
			});
			if (keys.length) {
				circle(keys);
			} else if (!sessionid) {
				alert('请输入你的Session ID!');
			} else {
				alert('请先选择要激活的游戏!');
			}
		});
		$('#redeemallsteamkey').on('click', function() {
			keys = [];
			i = 0;
			$.each($('.game-key-string'), (i, e) => {
				let key = $(e).find('input').val();
				keys.push(key);
			});
			if (!sessionid) {
				alert('请输入你的Session ID!');
			} else if (keys.length) {
				circle(keys);
			}
		});
	}

	function circle() {
		setTimeout(function() {
			if (i > (keys.length - 1)) return;
			window.open('https://store.steampowered.com/account/ajaxregisterkey/?product_key=' + keys[i] + '&sessionid=' + sessionid);
			i++;
			circle();
		}, 5000);
	}

	s_redeem();
	m_redeem();

})(jQuery);