// ==UserScript== // @name Steam Wishlist Checker // @namespace https://coding.net/u/sffxzzp // @version 0.04 // @description Check specified users that add the game to wishlist. // @author sffxzzp // @match *://steamcommunity.com/*/friendsthatplay/* // @icon https://store.steampowered.com/favicon.ico // @grant GM_xmlhttpRequest // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // @connect store.steampowered.com // @downloadURL none // ==/UserScript== (function() { var util = (function () { function util() {} util.xhr = function (xhrData) { return new Promise(function(resolve, reject) { if (!xhrData.xhr) { GM_xmlhttpRequest({ method: xhrData.method || "get", url: xhrData.url, responseType: xhrData.type || "", timeout: 3e4, onload: function onload(res) { return resolve({ response: res, body: res.response }); }, onerror: reject, ontimeout: reject }); } else { var xhr = new XMLHttpRequest(); xhr.open( xhrData.method || "get", xhrData.url, true ); if (xhrData.method === "POST") { xhr.setRequestHeader( "content-type", "application/x-www-form-urlencoded; charset=utf-8" ); } if (xhrData.cookie) xhr.withCredentials = true; xhr.responseType = xhrData.responseType || ""; xhr.timeout = 3e4; xhr.onload = function(ev) { var evt = ev.target; resolve({ response: evt, body: evt.response }); }; xhr.onerror = reject; xhr.ontimeout = reject; xhr.send(xhrData.data); } }); }; util.wrun = function (data) { setTimeout(data.run||null, data.ms); }; util.createElement = function (data) { var node; if (data.node) { node = document.createElement(data.node); if (data.content) { this.setElement({node: node, content: data.content}); } if (data.html) { node.innerHTML = data.html; } } return node; }; util.setElement = function (data) { if (data.node) { for (let name in data.content) { data.node.setAttribute(name, data.content[name]); } if (data.html!=undefined) { data.node.innerHTML = data.html; } } }; util.getElement = function (data) {}; return util; })(); var swc = (function () { function swc() {}; swc.prototype.getUsers = function () { var sAccounts = GM_getValue("swcAccounts"); if (sAccounts) { sAccounts = JSON.parse(sAccounts); } else { sAccounts = []; } return sAccounts; }; swc.prototype.get32id = function (steam64id) { var tmp = [], root = ["76561","197960","265728"]; tmp[0] = steam64id.substr(0,5); tmp[1] = steam64id.substr(5,6); tmp[2] = steam64id.substr(11,6); return (tmp[0]-root[0])*1000000000000+(tmp[1]-root[1])*1000000+(tmp[2]-root[2]); }; swc.prototype.getAppid = function () { return parseInt(/friendsthatplay\/(\d*)/ig.exec(location.href)[1]); }; swc.prototype.inArray = function (array, item) { if (array.indexOf(item)>-1) { return true; } else { return false; } }; swc.prototype.getXmlNode = function (xml, nodeName) { return xml.getElementsByTagName(nodeName)[0].textContent; }; swc.prototype.addToPage = function (user) { var _this = this; util.xhr({ url: "https://steamcommunity.com/profiles/"+user+"?xml=1", type: "xml" }).then(function (result) { let parser = new DOMParser(); let xmlDoc = parser.parseFromString(result.body, "text/xml"); let avatarMedium = _this.getXmlNode(xmlDoc, "avatarMedium"); let steamID = _this.getXmlNode(xmlDoc, "steamID"); let onlineState = _this.getXmlNode(xmlDoc, "onlineState"); let userblock = util.createElement({node: "div", content: {class: "friendBlock persona "+onlineState, "data-miniprofile": _this.get32id(user)}, html: '