Steam Add Free License

Add Free License

当前为 2021-08-24 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Steam Add Free License
// @namespace    http://tampermonkey.net/
// @version      1.02
// @description  Add Free License
// @author       UndCover
// @match        https://store.steampowered.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
	jQuery("#global_action_menu").append('<a id="btn_add_free" href="#"class="btnv6_blue_hoverfade btn_medium"><span>喜加一</span></a>');

	var dialog = jQuery('<div id="dlg_undcover" class="newmodal"style="position: fixed; z-index: 1000; max-width: 1503px; left: 541px; top: 277px;display: none;"><div class="modal_top_bar"></div><div class="newmodal_header_border"><div class="newmodal_header"><div id="btn_undcover_close" class="newmodal_close"></div><div class="title_text">喜加一激活框</div></div></div><div class="newmodal_content_border"><div class="newmodal_content"style="max-height: 631px;"><div style="float: left;width: 100%;"><input name="product_key"id="input_undcover"type="text"value=""placeholder="输入产品代码,在 Steam 上激活您的产品"></div><div class="newmodal_buttons"><div class="button_row"><a tabindex="300"href="#"class="btnv6_blue_hoverfade btn_medium"id="btn_undcover_confirm"><span>确认</span></a></div></div></div></div></div>');
	jQuery("body").append(dialog);
	jQuery("#input_undcover").css({
		"background-color": "rgba( 0, 0, 0, 0.4)",
		"color": "#fff",
		"border": "1px solid #000",
		"border-radius": "3px",
		"box-shadow": "1px 1px 0px #45556c",
		"width": "100%",
		"padding": "5px",
		"margin-top": "3px",
		"font-size": "16px",
		"line-height": "21px"
	});
	jQuery("#btn_add_free").click(function() {
		jQuery("#dlg_undcover").show();
	});
	jQuery("#btn_undcover_close").click(function(){
		jQuery("#dlg_undcover").hide();
	});

	// var dlgSuccess = jQuery('<div id="dlg_undcover_success"class="newmodal"style="position: fixed; z-index: 2000; top:100px;left:100px;display:none;"><div class="modal_top_bar"></div><div class="newmodal_header_border"><div class="newmodal_header"><div id="btn_undcover_close2"class="newmodal_close"></div></div></div><div class="newmodal_content_border"><div id="div_undcover_success"class="newmodal_content"><div id="receipt_area"class="leftcol"><div class="cart_area_body checkout_content_box free_game"><div class="checkout_tab checkout_content"><h2>成功!</h2><div class="add_free_content_success_area"><p>Ring of Elysium已被绑定至您的Steam帐户。</p><p>要访问新内容,只需在Steam库中启动此产品即可。</p></div><div class="rule"></div><div class="checkout_gotsteam_area"><h1>没有Steam?</h1><p>您需要Steam应用程序来访问您的新产品。</p><div id="gotsteam_buttons"><a href="steam://subscriptioninstall/222829"class="btn_blue leftbtn"><h3>是的,我已安装Steam</h3><h5>马上安装您的新游戏</h5></a><a href="https://media.st.dl.bscstorage.net/client/installer/SteamSetup.exe"class="btn_blue"><h3>没有,我还没安装Steam</h3><h5>免费下载</h5></a><div style="clear: left;"></div></div></div></div></div></div></div></div></div>');
	var dlgSuccess = jQuery('<div id="dlg_undcover_success"class="newmodal"style="position: fixed; z-index: 2000; top:100px;left:100px;display:none;"><div class="modal_top_bar"></div><div class="newmodal_header_border"><div class="newmodal_header"><div id="btn_undcover_close2"class="newmodal_close"></div></div></div><div class="newmodal_content_border"><div id="div_undcover_success"class="newmodal_content"></div></div></div>');

	jQuery("body").append(dlgSuccess);

	jQuery("#btn_undcover_close2").click(function(){
		jQuery("#dlg_undcover_success").hide();
	});

    jQuery("#input_undcover").val(jQuery("[name='subid']").val())

	jQuery("#btn_undcover_confirm").click(function(){
		var userAvatar = jQuery(".user_avatar");
		if(userAvatar.length > 0){
			var _subId = jQuery("#input_undcover").val();
			if(_subId != null && _subId.length > 0 ){
				jQuery.post(
					'//store.steampowered.com/checkout/addfreelicense',
					{
						action: 'add_to_cart',
						sessionid: g_sessionID,
						subid:_subId
					},
					function(data,status){
                        jQuery("#dlg_undcover_success").show();
                        jQuery("#div_undcover_success").html(data);
					}
				)
			}
		}else{
			alert("未登录");
		}
	});
})();