快速查询Steam游戏信息
目前為
// ==UserScript==
// @name Steam Info
// @namespace http://userscripts.org/users/deparsoul
// @description 快速查询Steam游戏信息
// @include http://steamdb.sinaapp.com/sync
// @grant GM_xmlhttpRequest
// @version 0.31
// ==/UserScript==
if(document.URL == 'http://steamdb.sinaapp.com/sync'){
exec('setScriptVersion('+addslashes(GM_info.script.version)+')');
load('http://steamcommunity.com/my/games?tab=all', 'own');
load('http://store.steampowered.com/dynamicstore/userdata/?id=1', 'userdata');
}else{
var script = document.createElement("script");
script.setAttribute("src", "http://steamdb.sinaapp.com/steam_info.js");
document.body.appendChild(script);
}
//Location hack
function exec(fn) {
location.assign(encodeURI("javascript:"+fn));
}
//Load page at url into element with id
function load(url, id){
GM_xmlhttpRequest({
method: "GET",
url: url,
onload: function(response) {
exec('proc_'+id+'("'+addslashes(response.responseText)+'")');
}
});
}
//Add slashes to string
function addslashes(string) {
return string.replace(/\\/g, '\\\\').
replace(/\u0008/g, '\\b').
replace(/\t/g, '\\t').
replace(/\n/g, '\\n').
replace(/\f/g, '\\f').
replace(/\r/g, '\\r').
replace(/'/g, '\\\'').
replace(/"/g, '\\"');
}