您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
Steam便捷加入购物车,不自动跳转购物车页面。
当前为
// ==UserScript== // @name Steam便捷加入购物车 // @namespace Steam便捷加入购物车 // @version 0.1 // @description Steam便捷加入购物车,不自动跳转购物车页面。 // @author HCLonely // @match https://store.steampowered.com/* // @grant GM_addStyle // @run-at document-end // ==/UserScript== (function($) { 'use strict'; function addToCart(appid){ $.ajax({ url:'https://store.steampowered.com/app/'+appid, type:'get', success:(data)=>{ try{ let addToCart=data.match(/\<form name\=\"add\_to\_cart[\w\W]*?\<\/form\>/gim); if(addToCart){ let inputArr=addToCart[0].match(/\<input type\=\"hidden\".*?\>/gim); let postData={}; for(let i=0;i<inputArr.length;i++){ let input=$(inputArr[i]); let key=input.attr('name'); let value=input.attr('value'); postData[key]=value; } $.ajax({ url:'https://store.steampowered.com/cart/', type:'post', data:postData, success:(data)=>{ try{ let test=new RegExp('\<div class\=\"cart_row.*?data\-ds\-appid\=\"'+appid+'\"','g'); if(test.test(data)){ alert("成功加入购物车!"); }else{ alert("加入购物车失败!"); } }catch(e){ alert('添加失败: \n'+e); } }, error:()=>{ alert("加入购物车失败!"); }, }); }else{ alert("没有找到添加购物车按钮,请手动添加!"); } }catch(e){ alert('添加失败: \n'+e); } }, error:()=>{ alert("获取游戏信息失败!"); }, }); } function addBtn(){ $('.ds_options').parent().not(':contains("添加至购物车")').append(`<div class="ds_options hclonely btnv6_green_white_innerfade"><span>添加至购物车</span></div>`); $('.ds_options.hclonely').click(function(e){ e.preventDefault(); addToCart($(this).parent().attr('data-ds-appid')); }); } addBtn(); setInterval(()=>{ if($('.ds_options').parent().not(':contains("添加至购物车")').length>0) addBtn(); },1500); GM_addStyle(` .hclonely{ position: absolute; right: 0; top: 25px; z-index: 999999; padding: 0 !important; } `); })(jQuery);