// ==UserScript== // @name steam一键移除 // @version 0.7.3 // @description steam一键取关鉴赏家,取关游戏,清空愿望单。 // @namespace https://greasyfork.org/users/133492 // @author HCLonely // @include *://store.steampowered.com/* // @include *://steamcommunity.com/* // @supportURL https://steamcn.com/t455167-1-1 // @require https://cdn.bootcss.com/sweetalert/2.1.2/sweetalert.min.js // @grant GM_xmlhttpRequest // @grant GM_addStyle // @run-at document-end // @connect steamcommunity.com // @connect steampowered.com // @downloadURL none // ==/UserScript== (function($) { 'use strict'; const url=window.location.href; let userName=""; let div=document.createElement("div"); div.setAttribute("id", "remove"); div.setAttribute("style", "background-color: #181f27;position:fixed;border-radius: 20px;width: 800px;height: 500px;margin: auto;top: 0;left: 0;right: 0;bottom: 0;z-index: 99999999999;display:none"); div.innerHTML=`
获取鉴赏家列表
获取关注游戏列表
获取愿望单列表

<\/div>

全选 反选

X `; document.getElementsByTagName("body")[0].appendChild(div); let a=document.createElement("a"); a.setAttribute("id", "remove_btn"); a.setAttribute("class", "menuitem supernav"); a.setAttribute("style", "cursor:pointer"); a.innerHTML="一键移除"; $(".supernav_container:first").append(a); a.onclick=function(){ if(window.location.host=="steamcommunity.com"){ if(confirm("此功能需要在商店页面运行,是否跳转?")) window.open("https://store.steampowered.com/","_self"); }else{ let username=document.getElementsByClassName("username"); if(username.length>0){ let user=$('a[data-miniprofile]'); if(user.length>0){ userName=user[0].innerText; $('#remove').show(); }else{ if(confirm("请先登录!")) window.open("https://store.steampowered.com/login/","_self"); } }else{ if(confirm("请先登录!")) window.open("https://store.steampowered.com/login/","_self"); } } }; $("#get_fcl").click(()=>{ $("#pro").text(""); $("#selectAll").attr("checked", false); $("#reverse").attr("checked", false); get_curators(); }); $("#get_fgl").click(()=>{ $("#pro").text(""); $("#selectAll").attr("checked", false); $("#reverse").attr("checked", false); get_follow_games(); }); $("#get_wl").click(()=>{ $("#pro").text(""); $("#selectAll").attr("checked", false); $("#reverse").attr("checked", false); get_wishlist(); }); $("#unf_c").click(function(){ if(!$(this).hasClass("disabled")){ let curators=[]; let curatorsChecked=$("p.checkbox input:checkbox:checked"); for(let i=0;i0?unfollow_curators(curators):alert("你还没有选中要取关的鉴赏家!"); } }); $("#unf_g").click(function(){ if(!$(this).hasClass("disabled")){ let games=[]; let gamesChecked=$("p.checkbox input:checkbox:checked"); for(let i=0;i0?unfollow_games(games):alert("你还没有选中要取关的游戏!"); } }); $("#rem_g").click(function(){ if(!$(this).hasClass("disabled")){ let games=[]; let gamesChecked=$("p.checkbox input:checkbox:checked"); for(let i=0;i0?remove_wishlist(games):alert("你还没有选中要移除愿望单的游戏!"); } }); //一键取关+移除愿望单 if(/https?:\/\/store.steampowered.com\/app\/[\w\W]*/.test(url)){ $("div.queue_control_button.queue_btn_ignore").after(`
一键移除
`); $(".queue_btn_remove>.queue_btn_inactive").click(()=>{ removeWishlist(); unFollow(); }); } let curators=[]; let unfC=0; let unfG=0; let remG=0; let page=1; let steam64ID=getCookie('steamRememberLogin')?getCookie('steamRememberLogin').slice(0,17):userName; //获取鉴赏家列表 function get_curators(){ let p=document.createElement("p"); p.setAttribute("style", "font-size:15px"); p.innerHTML=`获取鉴赏家列表...`; $("#info").append(p); p.scrollIntoView(); GM_xmlhttpRequest({ method: "GET", url: "https://store.steampowered.com/dynamicstore/userdata/?id="+userName+"&t="+new Date().getTime(), timeout: 1000*30, responseType: "json", onload: function (data) { if(data.status==200){ p.innerHTML+='成功!'; let curator=data.response.rgCurators; let curators=[]; let checkbox=''; Object.keys(curator).forEach(function(key){ checkbox+=`

${curator[key].name}

`; }); $("#setting").html(checkbox); if(Object.keys(curator).length>0){ $(".next").addClass("disabled"); $("#unf_c").removeClass("disabled"); }else{ p.innerHTML+="
关注鉴赏家列表为空!"; p.scrollIntoView(); } }else{ p.innerHTML+='失败!请刷新重试'; } } }); } //读取cookie function getCookie(name) { let arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); if(arr=document.cookie.match(reg)){ return unescape(arr[2]); }else{ return null; } } //取关鉴赏家 function unfollow_curators(curators,i=0){ i==0?$("#pro")[0].innerHTML=`取关鉴赏家进度: ${i} / ${curators.length}`:$("#ard")[0].innerHTML=`${i}`; let p=document.createElement("p"); p.innerHTML=`取关鉴赏家${curators[i].name}...`; $("#info").append(p); p.scrollIntoView(); GM_xmlhttpRequest({ method : "POST", url: "https://store.steampowered.com/curators/ajaxfollow", timeout: 1000*30, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, data:`clanid=${curators[i].id}&sessionid=${g_sessionID}&follow=0`, onload: function (data) { if(data.status==200){ if(data.response.success.success==1){ p.innerHTML+='成功!'; unfC++; }else{ p.innerHTML+='失败!'; } }else{ p.innerHTML+='失败!'; } $("#ard")[0].innerHTML=`${i+1}`; if(i{unfollow_curators(curators,i)},1500); }else{ let p=document.createElement("p"); p.setAttribute("style", "font-size:15px"); p.innerHTML=`取关所有鉴赏家完成,${unfC}个鉴赏家取关成功,${curators.length-unfC}个鉴赏家取关失败!点此查看结果`; unfC=0; $("#info").append(p); p.scrollIntoView(); } } }); } //获取关注游戏列表 function get_follow_games(){ let p=document.createElement("p"); p.setAttribute("style", "font-size:15px"); p.innerHTML=`获取已关注游戏列表...`; $("#info").append(p); p.scrollIntoView(); GM_xmlhttpRequest({ method: "GET", url: "https://steamcommunity.com/id/"+userName+"/followedgames/?t="+new Date().getTime(), timeout: 1000*30, onload: function (data) { if(data.status==200){ p.innerHTML+='成功!'; let followGame=data.responseText.match(/\
\[\w\W]*?\<\/a\>\<\/div\>/gim); if(followGame&&(followGame.length>0)){ session_id = data.responseText.match(/g_sessionID = \"(.+?)\";/)[1]; let gameList=unique(followGame.map((e)=>{ return {'id':e.match(/app\/[\d]+?\"/gim)[0].match(/[\d]+/gim)[0],'name':e.replace(/\
/gim,"").match(/\>[\w\W]+?\/gim,"")} })); let checkbox=''; for(let i=0;i${gameList[i].name}

`; } $("#setting").html(checkbox); $(".next").addClass("disabled"); $("#unf_g").removeClass("disabled"); }else{ p.innerHTML+="
关注游戏列表为空!"; p.scrollIntoView(); } }else{ p.innerHTML+='失败!请刷新重试'; } } }); } //取关游戏 function unfollow_games(games,i=0){ i==0?$("#pro")[0].innerHTML=`取关游戏进度: ${i} / ${games.length}`:$("#ard")[0].innerHTML=`${i}`; let gameId=games[i].id; let gameName=games[i].name; let p=document.createElement("p"); p.innerHTML=`取关游戏${gameName}...`; $("#info").append(p); p.scrollIntoView(); GM_xmlhttpRequest({ method : "POST", url: "https://steamcommunity.com/app/"+gameId+"/stopfollowing", timeout: 1000*30, headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, data:`sessionid=${g_sessionID}`, onload: function (data) { if(data.status==200&&(data.responseText=='null')){ p.innerHTML+='成功!'; unfG++; }else{ p.innerHTML+='失败!'; } $("#ard")[0].innerHTML=`${i+1}`; if(i{unfollow_games(games,i)},1500); }else{ let p=document.createElement("p"); p.setAttribute("style", "font-size:15px"); p.innerHTML=`取关所有游戏完成,${unfG}个游戏取关成功,${games.length-unfG}个游戏取关失败!点此查看结果`; unfG=0; $("#info").append(p); p.scrollIntoView(); } } }); } //获取愿望单列表 function get_wishlist(){ let p=document.createElement("p"); p.setAttribute("style", "font-size:15px"); p.innerHTML=`获取愿望单列表...`; $("#info").append(p); p.scrollIntoView(); GM_xmlhttpRequest({ method: "GET", url: "https://store.steampowered.com/dynamicstore/userdata/?id="+userName+"&t="+new Date().getTime(), timeout: 1000*30, responseType: "json", onload: function (data) { console.log(data); if(data.status==200){ let wishlistGame=data.response.rgWishlist; let checkbox=''; for(let i=0;i${wishlistGame[i]}

`; } $("#setting").html(checkbox); p.innerHTML+='成功!'; if(wishlistGame.length>0){ $(".next").addClass("disabled"); $("#rem_g").removeClass("disabled"); }else{ p.innerHTML+="
愿望单为空!"; p.scrollIntoView(); } }else{ p.innerHTML+='失败!请刷新重试'; } } }); } //移除愿望单 function remove_wishlist(wishlist,i=0){ i==0?$("#pro")[0].innerHTML=`取关游戏进度: ${i} / ${wishlist.length}`:$("#ard")[0].innerHTML=`${i}`; let gameId=wishlist[i]; let p=document.createElement("p"); p.innerHTML=`移除游戏${gameId}...`; document.getElementById("info").appendChild(p); p.scrollIntoView(); GM_xmlhttpRequest({ method : "POST", url: "https://store.steampowered.com/wishlist/profiles/"+userName+"/remove/", timeout: 1000*30, cache: false, responseType: "json", headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, data:`appid=${gameId}&sessionid=${g_sessionID}`, onload: function (data) { if(data.status==200){ if(data.response.success==1){ p.innerHTML+='成功!'; remG++; }else{ p.innerHTML+='失败!'; } }else{ p.innerHTML+='失败!'; } $("#ard")[0].innerHTML=`${i+1}`; if(i{remove_wishlist(wishlist,i)},1500); }else{ let p=document.createElement("p"); p.setAttribute("style", "font-size:15px"); p.innerHTML=`移除愿望单游戏完成,${remG}个游戏移除成功,${wishlist.length-remG}个游戏移除失败!点此查看结果`; remG=0; $("#info").append(p); p.scrollIntoView(); } } }); } //一键取关+移除愿望单 function getAppid(){ return url.replace("https://store.steampowered.com/app/","").match(/[\d]+?\//)[0].replace("/",""); } function removeWishlist(){ $.ajax({ type: "post", url: "https://store.steampowered.com/wishlist/profiles/"+steam64ID+"/remove/", datatype: "json", cache: false, data:{ sessionid:g_sessionID, appid:getAppid(), }, crossDomain:true, xhrFields: { withCredentials: true }, success: function (data) { if(data.success==true){ if($("#add_to_wishlist_area").length>0){ $("#add_to_wishlist_area").show(); }else{ let btn=$("a.queue_btn_active:contains('已在愿望单中')"); btn.removeClass("queue_btn_active"); btn.html("已移除"); } $("#add_to_wishlist_area_success").hide(); } }, }); } function unFollow(){ $.ajax({ type: "post", url: '//store.steampowered.com/explore/followgame/', datatype: "json", cache: false, data:{ sessionid:g_sessionID, appid:getAppid(), unfollow: '1', }, crossDomain:true, xhrFields: { withCredentials: true }, success: function (data) { if(data==true){ $("div.queue_control_button.queue_btn_follow>.queue_btn_inactive").show(); $("div.queue_control_button.queue_btn_follow>.queue_btn_active").hide(); } } }); } $("p.checkbox input:checkbox").click(()=>{ $("#selectAll").attr("checked", false); }); $("#selectAll").click(function() { let thisChexk=this.checked; $("p.checkbox input:checkbox").each(function() { $(this).attr("checked", thisChexk); }); }); $("#reverse").click(function() { $("#selectAll").attr("checked", false); $("p.checkbox input:checkbox").each(function() { this.checked = !this.checked; }); }); //数组去重 function unique(arr){ return [...new Set(arr)]; } GM_addStyle(` #output { background-color: #1e3a4c; border-radius: 3px; border: 1px solid rgba( 0, 0, 0, 0.3); box-shadow: 1px 1px 0px rgba( 255, 255, 255, 0.2); color: #fff; margin: 0 55px 0 45px; height: 320px; padding: 0 5px; } #setting { width: 50%; height: 100%; position: relative; overflow-y: auto; overflow-x: hidden; } #info { position: relative; left: 50%; top: -320px; width: 50%; height: 100%; border-left-style: dashed; padding-left: 5px; overflow-y: auto; overflow-x: hidden; } .checkbox,#info p { font-size: 15px; } h4.checkbox { bottom: -10px; z-index: 99999; margin: 10px 45px; } .btn_wrapper { margin: 2px 0; margin-right: 8px; display: inline-block; } .disabled { cursor: not-allowed !important; background: #6b7373 !important; color: #8da5a5 !important; } .disabled:hover { cursor: not-allowed !important; background: #6b7373 !important; color: #8da5a5 !important; } .big_button { cursor: pointer; width: 226px; height: 29px; font-family: "Motiva Sans", Sans-serif; font-weight: 300; display: inline-block; font-size: 18px; line-height: 28px; color: #66c0f4; text-align: center; background-image: url(//steamstore-a.akamaihd.net/public/images/v6/home/background_spotlight.jpg); background-position-y: -105px; border-radius: 3px; box-shadow: 0 0 4px #000; } .queue_btn_remove { padding-left: 5px; } `); })(jQuery);