// ==UserScript==
// @name steam一键移除
// @version 0.2
// @description steam一键取关鉴赏家,取关游戏,清空愿望单。
// @namespace https://greasyfork.org/users/133492
// @author HCLonely
// @match *://store.steampowered.com/*
// @match *://steamcommunity.com/*
// @include *://store.steampowered.com/app/*
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @downloadURL none
// ==/UserScript==
(function() {
'use strict';
var url=window.location.href;
var userName="";
window.onload=function(){
var 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);
var a=document.createElement("a");
a.setAttribute("id", "remove_btn");
a.setAttribute("class", "menuitem supernav");
a.setAttribute("style", "cursor:pointer");
a.innerHTML="一键移除";
document.getElementsByClassName("supernav_container")[0].appendChild(a);
document.getElementById("remove_btn").onclick=function(){
var username=document.getElementsByClassName("username");
if(username.length>0){
document.getElementById('remove').style.display='block';
var user=getCookie("steamRememberLogin");
if(user){
userName=user.substring(0,17);
}else{
if(confirm("请先登录!")){
window.open("https://store.steampowered.com/login/","_self");
}
}
}else{
if(confirm("请先登录!")){
window.open("https://store.steampowered.com/login/","_self");
}
}
};
document.getElementById("unf_c").onclick=function(){
if(confirm("请确认是否取关所有鉴赏家? \n!!!此操作不可恢复请谨慎选择!")){
get_curators();
}
};
document.getElementById("unf_g").onclick=function(){
if(confirm("请确认是否取关所有游戏? \n!!!此操作不可恢复请谨慎选择!")){
get_follow_games();
}
};
document.getElementById("rem_g").onclick=function(){
if(confirm("请确认是否移除所有愿望单游戏? \n!!!此操作不可恢复请谨慎选择!")){
get_wishlist();
}
};
//一键取关+移除愿望单
if(/https?:\/\/store.steampowered.com\/app\/[\w\W]*/.test(url)){
jQuery("div.queue_control_button.queue_btn_ignore").after(`
`);
jQuery(".queue_btn_remove>.queue_btn_inactive").click(function(){
removeWishlist();
unFollow();
});
}
}
var curators=[];
var unfC=0;
var unfG=0;
var remG=0;
var page=1;
var sessionid=getCookie("sessionid");
var session_id;
//获取鉴赏家列表
function get_curators(){
var p=document.createElement("p");
p.setAttribute("id", "p_curator");
p.setAttribute("style", "font-size:15px");
p.innerHTML=`获取鉴赏家列表...`;
document.getElementById("info").appendChild(p);
p.scrollIntoView();
GM_xmlhttpRequest({
method: "GET",
url: "https://store.steampowered.com/dynamicstore/userdata/?id="+userName,
timeout: 1000*30,
responseType: "json",
onload: function (data) {
if(data.status==200){
var curator=data.response.rgCurators;
var curators=[];
document.getElementById("p_curator").innerHTML+='
成功!';
Object.keys(curator).forEach(function(key){
curators.push(curator[key]);
});
if(curators.length>0){
unfollow_curators(0,curators);
}else{
document.getElementById("p_curator").innerHTML+="
关注鉴赏家列表为空!";
}
}else{
document.getElementById("p_curator").innerHTML+='
失败!请刷新重试';
}
}
});
}
/*
function get_curators(s){
var p=document.createElement("p");
p.setAttribute("id", "p_"+page);
p.setAttribute("style", "font-size:15px");
p.innerHTML=`获取鉴赏家列表:第${page}页...`;
document.getElementById("info").appendChild(p);
p.scrollIntoView();
GM_xmlhttpRequest({
method: "GET",
url: "https://store.steampowered.com/curators/ajaxgetcurators//?query=&start="+s+"&count=50&filter=mycurators",
timeout: 1000*30,
responseType: "json",
onload: function (data) {
if(data.status==200){
document.getElementById("p_"+page).innerHTML+='
成功!';
if(data.response.results_html.match(/var g_rgTopCurators[\w\W]*?\}\]\;/gim)){
page++;
var js=data.response.results_html.match(/var g_rgTopCurators[\w\W]*?\}\]\;/gim)[0];
js=js.replace("var g_rgTopCurators = ","");
js=js.replace(/\;$/gim,"");
s==0?curators=JSON.parse(js):curators.push.apply(curators,JSON.parse(js));
curators.length<50?unfollow_curators(0,curators):(s==50?unfollow_curators(0,curators):get_curators(50));
}else{
document.getElementById("p_"+page).innerHTML+="
关注鉴赏家列表为空!";
}
}else{
document.getElementById("p_"+page).innerHTML+='
失败!请刷新重试';
}
}
});
}
*/
//读取cookie
function getCookie(name) {
var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg)){
return unescape(arr[2]);
}else{
return null;
}
}
//取关鉴赏家
function unfollow_curators(i=0,curators){
if(i==0){
document.getElementById("pro").innerHTML=`取关鉴赏家进度:
${i} / ${curators.length}`;
}else{
document.getElementById("ard").innerHTML=`${i}`;
}
var p=document.createElement("p");
p.setAttribute("id", "c_"+curators[i].clanid);
p.innerHTML=`取关鉴赏家
${curators[i].name}...`;
document.getElementById("info").appendChild(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].clanid}&sessionid=${sessionid}&follow=0`,
onload: function (data) {
if(data.status==200){
if(data.response.success==1){
document.getElementById("c_"+curators[i].clanid).innerHTML+='
成功!';
unfC++;
}else{
document.getElementById("c_"+curators[i].clanid).innerHTML+='
失败!';
}
}else{
document.getElementById("c_"+curators[i].clanid).innerHTML+='
失败!';
}
document.getElementById("ard").innerHTML=`${i+1}`;
if(i
点此查看结果`;
document.getElementById("info").appendChild(pe);
pe.scrollIntoView();
}
}
});
}
//获取关注游戏列表
function get_follow_games(){
var p=document.createElement("p");
p.setAttribute("id", "p_follow");
p.setAttribute("style", "font-size:15px");
p.innerHTML=`获取已关注游戏列表...`;
document.getElementById("info").appendChild(p);
p.scrollIntoView();
//var followGame=document.getElementsByTagName("body")[0].innerHTML.match(/[\w\W]*?<\/div>[\w\W]*?