Steam Redeem Sub

Steam激活Sub

目前为 2019-08-13 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Steam Redeem Sub
  3. // @namespace Steam Redeem Sub
  4. // @version 0.2
  5. // @description Steam激活Sub
  6. // @author HCLonely
  7. // @include /https?:\/\/store\.steampowered\.com\/account\/licenses\/(\?sub\=[\w\W]{0,})?/
  8. // @include *://steamdb.info/freepackages*
  9. // @grant GM_registerMenuCommand
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. const url=window.location.href;
  17.  
  18. //steamdb.info
  19. if(/https?:\/\/steamdb\.info\/freepackages\//.test(url)){//点击自动跳转到激活页面
  20. let activateConsole = function(e) {
  21. document.execCommand("Copy");
  22. let jsText = window.getSelection().toString().trim() || e.target.value;
  23. if (/\(function\(\)[\w\W]{0,}let freePackages \=[\w\W]{0,}\}\(\)\)\;/.test(jsText)) {
  24. let freePackages=jsText.match(/[\d]{2,},[\s]\/\/ \[REMOVE\]/g).join("-").match(/[\d]{2,},/g).join("");
  25. window.open("https://store.steampowered.com/account/licenses/?sub=" + freePackages,"_self");
  26. }
  27. };
  28. let fp=setInterval(()=>{
  29. if(document.getElementById("freepackages")){
  30. document.getElementById("freepackages").innerHTML=`<button>激活SUB</button>`+document.getElementById("freepackages").innerHTML;
  31. document.getElementById("freepackages").onclick=activateConsole;
  32. clearInterval(fp);
  33. }
  34. },1000);
  35. //GM_registerMenuCommand
  36. }else{
  37. function redeemSub(e){
  38. let subText=e||document.getElementById("gameSub").value;
  39. if(subText){
  40. let ownedPackages = {};
  41. jQuery( '.account_table a' ).each( function( i, el ){
  42. let match = el.href.match( /javascript:RemoveFreeLicense\( ([0-9]+), '/ );
  43. if( match !== null ){
  44. ownedPackages[ +match[ 1 ] ] = true;
  45. }
  46. } );
  47. let freePackages =subText.match(/[\d]{2,}/g);
  48. let i = 0,
  49. loaded = 0,
  50. packae = 0,
  51. total = freePackages.length,
  52. modal = ShowBlockingWaitDialog( 'Executing…',
  53. 'Please wait until all requests finish. Ignore all the errors, let it finish.' );
  54. for( ; i < total; i++ ){
  55. packae = freePackages[ i ];
  56. if( ownedPackages[ packae ] ){
  57. loaded++;
  58. continue;
  59. }
  60. jQuery.post(
  61. '//store.steampowered.com/checkout/addfreelicense',
  62. {
  63. action: 'add_to_cart',
  64. sessionid: g_sessionID,
  65. subid: packae
  66. }
  67. ).always( function( )
  68. {
  69. loaded++;
  70. modal.Dismiss();
  71. if( loaded >= total )
  72. {
  73. window.open("https://store.steampowered.com/account/licenses/","_self");
  74. }
  75. else
  76. {
  77. modal = ShowBlockingWaitDialog( 'Executing…',
  78. 'Loaded <b>' + loaded + '</b>/' + total + '.' );
  79. }
  80. }
  81. );
  82. }
  83. }
  84. }
  85. function cc(){
  86. jQuery.ajax({
  87. url:"//store.steampowered.com/cart/",
  88. type:"get",
  89. success:function(data){
  90. if(data.match(/id\=\"usercountrycurrency_trigger\"[\w\W]*?\>[w\W]*?\<\/a/gim)){
  91. let c=data.match(/id\=\"usercountrycurrency_trigger\"[\w\W]*?\>[w\W]*?\<\/a/gim)[0].replace(/id\=\"usercountrycurrency_trigger\"[\w\W]*?\>|\<\/a/g,"");
  92. let thisC=data.match(/id\=\"usercountrycurrency\"[\w\W]*?value=\".*?\"/gim)[0].match(/value=\".*?\"/gim)[0].replace(/value=\"|\"/g,"");
  93. let div=data.match(/\<div class=\"currency_change_options\"\>[\w\W]*?\<p/gim)[0].replace(/[\s]*?\<p/gim,"")+"</div>";
  94. jQuery("body").append(`<div id="ccDiv" style="position:fixed;margin:auto;z-index: 1000;width:629px;height:228px;top:20px;bottom:20px;left:20px;right:20px;background-color:#232b34"><div class="newmodal_header_border"><div class="newmodal_header"><div class="newmodal_close"></div><div id="nowCountry" class="ellipsis" data-country="${thisC}" style="font-size:20px;">转换商店和钱包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前国家/地区:${c}</div></div></div><div style="padding:20px">${div}</div></div>`);
  95. jQuery(".currency_change_option").click(function(){
  96. changeCountry(jQuery(this).attr("data-country"));
  97. });
  98. jQuery(".newmodal_close").click(function(){
  99. jQuery("#ccDiv").remove();
  100. });
  101. }else{
  102. alert("需要挂相应地区的梯子!");
  103. }
  104. },
  105. error:()=>{
  106. alert("获取当前国家/地区失败!");
  107. }
  108. });
  109. }
  110. function changeCountry(country){
  111. jQuery.ajax({
  112. url:"//store.steampowered.com/account/setcountry",
  113. type:"post",
  114. data:{
  115. sessionid:document.cookie.match(/sessionid\=.*?\;/gim)[0].replace(/sessionid\=|\;/g,""),
  116. "cc":country
  117. },
  118. complete:function(data){
  119. jQuery.ajax({
  120. url:"//store.steampowered.com/cart/",
  121. type:"get",
  122. success:function(data){
  123. let c=data.match(/id\=\"usercountrycurrency_trigger\"[\w\W]*?\>[w\W]*?\<\/a/gim)[0].replace(/id\=\"usercountrycurrency_trigger\"[\w\W]*?\>|\<\/a/g,"");
  124. let thisC=data.match(/id\=\"usercountrycurrency\"[\w\W]*?value=\".*?\"/gim)[0].match(/value=\".*?\"/gim)[0].replace(/value=\"|\"/g,"");
  125. let div=data.match(/\<div class=\"currency_change_options\"\>[\w\W]*?\<p/gim)[0].replace(/[\s]*?\<p/gim,"")+"</div>";
  126. jQuery("#ccDiv").html(`<div class="newmodal_header_border"><div class="newmodal_header"><div class="newmodal_close"></div><div id="nowCountry" class="ellipsis" data-country="${thisC}" style="font-size:20px;">转换商店和钱包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;当前国家/地区:${c}</div></div></div><div style="padding:20px">${div}</div>`);
  127. jQuery(".currency_change_option").click(function(){
  128. changeCountry(jQuery(this).attr("data-country"));
  129. });
  130. jQuery(".newmodal_close").click(function(){
  131. jQuery("#ccDiv").remove();
  132. });
  133. if(thisC===country){
  134. alert("更换成功!");
  135. }else{
  136. alert("更换失败!");
  137. }
  138. },
  139. error:()=>{
  140. alert("获取当前国家/地区失败!");
  141. }
  142. });
  143. }
  144. });
  145. }
  146. jQuery('.pageheader').parent().append('<div style="float: left;";>' +
  147. '<textarea class="registerkey_input_box_text" rows="1"' + 'name="product_key"' +
  148. ' id="gameSub" placeholder="输入SUB,多个SUB之间用英文逗号连接"' + 'value=""' + 'color:#fff;' +
  149. ' style="margin: 3px 0px 0px; width: 400px; height: 15px;background-color:#102634; padding: 6px 18px 6px 18px; font-weight:bold; color:#fff;"></textarea>' +
  150. ' &nbsp ' + '</div>' + '<a tabindex="300" class="btnv6_blue_hoverfade btn_medium"' +
  151. ' style="width: 95px; height: 30px;"' +
  152. ' id="buttonSUB"><span>激活SUB</span></a>'+ '<a tabindex="300" class="btnv6_blue_hoverfade btn_medium"' +
  153. ' style="width: 125px; height: 30px;"' +
  154. ' id="changeCountry"><span>更改国家/地区</span></a>');
  155. jQuery('#buttonSUB').click(redeemSub);
  156. jQuery('#changeCountry').click(cc);
  157. if (url.includes("sub=")){
  158. setTimeout(()=>{redeemSub(url)},2000);
  159. }
  160. }
  161. })();

QingJ © 2025

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