Greasy Fork

Shined up real nice.

Steam Info

快速查询Steam游戏信息

After trying this script, you can ask a question about it, review it, or report it.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// ==UserScript==
// @name        Steam Info
// @namespace   http://userscripts.org/users/deparsoul
// @description 快速查询Steam游戏信息
// @include     http://steamdb.sinaapp.com/sync
// @include     https://steamdb.steamcn.com/sync
// @grant       GM_xmlhttpRequest
// @version     0.37
// ==/UserScript==

if (document.URL == 'https://steamdb.steamcn.com/sync' || document.URL == 'http://steamdb.sinaapp.com/sync') {
    exec('setScriptVersion(' + addslashes(GM_info.script.version) + ')');
    var nocache = '_=' + Math.floor(Math.random() * 100000);
    load('http://steamcommunity.com/my/games?tab=all', 'own');
    load('http://store.steampowered.com/dynamicstore/userdata/?' + nocache, 'userdata');
    load('http://www.desura.com/games/ajax/json/all?collection=t&' + nocache, 'desura');
} else {
    var script = document.createElement("script");
    script.setAttribute("src", "https://steamdb.steamcn.com/steam_info.js");
    document.body.appendChild(script);
}

//Script Injection
function exec(fn) {
    var script = document.createElement('script');
    script.setAttribute("type", "application/javascript");
    script.textContent = fn;
    document.body.appendChild(script);
    document.body.removeChild(script);
}

//Load url and call proc function
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, '\\"');
}