Steam Info

快速查询Steam游戏信息

  1. // ==UserScript==
  2. // @name Steam Info
  3. // @namespace http://userscripts.org/users/deparsoul
  4. // @description 快速查询Steam游戏信息
  5. // @include http://steamdb.sinaapp.com/sync
  6. // @include https://steamdb.keylol.com/sync
  7. // @grant GM_xmlhttpRequest
  8. // @version 0.41
  9. // @connect steamcommunity.com
  10. // @connect store.steampowered.com
  11. // @connect www.desura.com
  12. // ==/UserScript==
  13.  
  14. if (document.URL == 'https://steamdb.keylol.com/sync' || document.URL == 'http://steamdb.sinaapp.com/sync') {
  15. exec('setScriptVersion(' + addslashes(GM_info.script.version) + ')');
  16. var nocache = '_=' + Math.floor(Math.random() * 100000);
  17. load('https://steamcommunity.com/my/games?tab=all', 'own');
  18. load('https://store.steampowered.com/dynamicstore/userdata/?' + nocache, 'userdata');
  19. //load('http://www.desura.com/games/ajax/json/all?collection=t&' + nocache, 'desura');
  20. } else {
  21. var script = document.createElement("script");
  22. script.setAttribute("src", "https://steamdb.keylol.com/steam_info.js");
  23. document.body.appendChild(script);
  24. }
  25.  
  26. //Script Injection
  27. function exec(fn) {
  28. var script = document.createElement('script');
  29. script.setAttribute("type", "application/javascript");
  30. script.textContent = fn;
  31. document.body.appendChild(script);
  32. document.body.removeChild(script);
  33. }
  34.  
  35. //Load url and call proc function
  36. function load(url, id) {
  37. try {
  38. GM_xmlhttpRequest({
  39. method: "GET",
  40. url: url,
  41. onload: function(response) {
  42. exec('proc_' + id + '("' + addslashes(response.responseText) + '")');
  43. }
  44. });
  45. } catch(e) {
  46. alert('如果您最近更新了Firefox之后发现脚本无法同步,请参考跳转后页面');
  47. location.href = 'https://keylol.com/t329493-1-1';
  48. }
  49. }
  50.  
  51. //Add slashes to string
  52. function addslashes(string) {
  53. return string.replace(/\\/g, '\\\\').
  54. replace(/\u0008/g, '\\b').
  55. replace(/\t/g, '\\t').
  56. replace(/\n/g, '\\n').
  57. replace(/\f/g, '\\f').
  58. replace(/\r/g, '\\r').
  59. replace(/'/g, '\\\'').
  60. replace(/"/g, '\\"');
  61. }