Steam Wishlist Checker

Check specified users that add the game to wishlist.

目前为 2018-06-02 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Steam Wishlist Checker
  3. // @namespace https://coding.net/u/sffxzzp
  4. // @version 0.04
  5. // @description Check specified users that add the game to wishlist.
  6. // @author sffxzzp
  7. // @match *://steamcommunity.com/*/friendsthatplay/*
  8. // @icon https://steamcommunity.com/favicon.ico
  9. // @grant GM_xmlhttpRequest
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @grant GM_deleteValue
  13. // @connect store.steampowered.com
  14. // ==/UserScript==
  15.  
  16. (function() {
  17. var util = (function () {
  18. function util() {}
  19. util.xhr = function (xhrData) {
  20. return new Promise(function(resolve, reject) {
  21. if (!xhrData.xhr) {
  22. GM_xmlhttpRequest({
  23. method: xhrData.method || "get",
  24. url: xhrData.url,
  25. responseType: xhrData.type || "",
  26. timeout: 3e4,
  27. onload: function onload(res) {
  28. return resolve({ response: res, body: res.response });
  29. },
  30. onerror: reject,
  31. ontimeout: reject
  32. });
  33. } else {
  34. var xhr = new XMLHttpRequest();
  35. xhr.open(
  36. xhrData.method || "get",
  37. xhrData.url,
  38. true
  39. );
  40. if (xhrData.method === "POST") {
  41. xhr.setRequestHeader(
  42. "content-type",
  43. "application/x-www-form-urlencoded; charset=utf-8"
  44. );
  45. }
  46. if (xhrData.cookie) xhr.withCredentials = true;
  47. xhr.responseType = xhrData.responseType || "";
  48. xhr.timeout = 3e4;
  49. xhr.onload = function(ev) {
  50. var evt = ev.target;
  51. resolve({ response: evt, body: evt.response });
  52. };
  53. xhr.onerror = reject;
  54. xhr.ontimeout = reject;
  55. xhr.send(xhrData.data);
  56. }
  57. });
  58. };
  59. util.wrun = function (data) {
  60. setTimeout(data.run||null, data.ms);
  61. };
  62. util.createElement = function (data) {
  63. var node;
  64. if (data.node) {
  65. node = document.createElement(data.node);
  66. if (data.content) {
  67. this.setElement({node: node, content: data.content});
  68. }
  69. if (data.html) {
  70. node.innerHTML = data.html;
  71. }
  72. }
  73. return node;
  74. };
  75. util.setElement = function (data) {
  76. if (data.node) {
  77. for (let name in data.content) {
  78. data.node.setAttribute(name, data.content[name]);
  79. }
  80. if (data.html!=undefined) {
  81. data.node.innerHTML = data.html;
  82. }
  83. }
  84. };
  85. util.getElement = function (data) {};
  86. return util;
  87. })();
  88. var swc = (function () {
  89. function swc() {};
  90. swc.prototype.getUsers = function () {
  91. var sAccounts = GM_getValue("swcAccounts");
  92. if (sAccounts) {
  93. sAccounts = JSON.parse(sAccounts);
  94. }
  95. else {
  96. sAccounts = [];
  97. }
  98. return sAccounts;
  99. };
  100. swc.prototype.get32id = function (steam64id) {
  101. var tmp = [], root = ["76561","197960","265728"];
  102. tmp[0] = steam64id.substr(0,5);
  103. tmp[1] = steam64id.substr(5,6);
  104. tmp[2] = steam64id.substr(11,6);
  105. return (tmp[0]-root[0])*1000000000000+(tmp[1]-root[1])*1000000+(tmp[2]-root[2]);
  106. };
  107. swc.prototype.getAppid = function () {
  108. return parseInt(/friendsthatplay\/(\d*)/ig.exec(location.href)[1]);
  109. };
  110. swc.prototype.inArray = function (array, item) {
  111. if (array.indexOf(item)>-1) {
  112. return true;
  113. }
  114. else {
  115. return false;
  116. }
  117. };
  118. swc.prototype.getXmlNode = function (xml, nodeName) {
  119. return xml.getElementsByTagName(nodeName)[0].textContent;
  120. };
  121. swc.prototype.addToPage = function (user) {
  122. var _this = this;
  123. util.xhr({
  124. url: "https://steamcommunity.com/profiles/"+user+"?xml=1",
  125. type: "xml"
  126. }).then(function (result) {
  127. let parser = new DOMParser();
  128. let xmlDoc = parser.parseFromString(result.body, "text/xml");
  129. let avatarMedium = _this.getXmlNode(xmlDoc, "avatarMedium");
  130. let steamID = _this.getXmlNode(xmlDoc, "steamID");
  131. let onlineState = _this.getXmlNode(xmlDoc, "onlineState");
  132. let userblock = util.createElement({node: "div", content: {class: "friendBlock persona "+onlineState, "data-miniprofile": _this.get32id(user)}, html: '<a class="friendBlockLinkOverlay" href="https://steamcommunity.com/profiles/'+user+'"></a><div class="playerAvatar '+onlineState+'"><img src="'+avatarMedium+'"></div><div class="friendBlockContent">'+steamID+'<br><span class="friendSmallText"><br><a class="whiteLink friendBlockInnerLink" href="https://steamcommunity.com/profiles/'+user+'/wishlist">查看愿望单</a></span></div>'});
  133. document.getElementById("swcbody").appendChild(userblock);
  134. });
  135. };
  136. swc.prototype.addView = function () {
  137. var mList = document.getElementById("memberList");
  138. let header = document.getElementsByClassName("mainSectionHeader");
  139. header = header[header.length-1].cloneNode(true);
  140. header.innerHTML += ' ** ';
  141. let settings = util.createElement({node: "a", content: {href: "javascript:void(0);"}, html:"设置"});
  142. settings.onclick = function () {
  143. var sAccounts = GM_getValue("swcAccounts");
  144. if (sAccounts) {
  145. sAccounts = JSON.parse(sAccounts).join(',');
  146. }
  147. else {
  148. sAccounts = "";
  149. }
  150. console.log(sAccounts);
  151. var input = prompt("请输入要检查的Steam 64位ID\n按英文逗号分割", sAccounts);
  152. if (input) {
  153. var accounts = input.split(',');
  154. GM_setValue("swcAccounts", JSON.stringify(accounts));
  155. }
  156. }
  157. header.appendChild(settings);
  158. let clear = util.createElement({node: "a", content: {style: "padding-left: 20px;", href: "javascript:void(0);"}, html: "清空"});
  159. clear.onclick = function () {
  160. if (confirm("确定要清空么?")) {
  161. GM_deleteValue("swcAccounts");
  162. alert("清空完毕!");
  163. }
  164. };
  165. header.appendChild(clear);
  166. mList.appendChild(header);
  167. let body = util.createElement({node: "div", content: {id: "swcbody", class: "profile_friends responsive_friendblocks"}});
  168. mList.appendChild(body);
  169. };
  170. swc.prototype.run = function () {
  171. var _this = this;
  172. _this.addView();
  173. let users = _this.getUsers();
  174. let appid = _this.getAppid();
  175. for (let i=0;i<users.length;i++) {
  176. util.xhr({
  177. url: "https://store.steampowered.com/wishlist/profiles/"+users[i]
  178. }).then(function (result) {
  179. let userWishlist = result;
  180. let wishlistData = /g_rgWishlistData = (.*?);/ig.exec(result.body)[1];
  181. wishlistData = JSON.parse(wishlistData);
  182. for (let j=0;j<wishlistData.length;j++) {
  183. if (wishlistData[j].appid == appid) {
  184. _this.addToPage(users[i]);
  185. break;
  186. }
  187. }
  188. });
  189. }
  190. };
  191. return swc;
  192. })();
  193. var program = new swc();
  194. program.run();
  195. })();

QingJ © 2025

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