回复
17
查看
544
收藏
5

8

赠楼

61%

赠楼率

2765

蒸汽

49

主题

2730

帖子

3386

积分
发表于 2 小时前 · 广东 | 显示全部楼层 |阅读模式
本帖最后由 147406 于 2026-11-26 11:05 编辑

没蓝绿插件用太难受了,这个只是临时修复脚本,坛子的sync因为换了个域名会有跨域问题读不到数据,所以直接从本地读出来就可以临时用

去油猴添加新脚本就好
  1. // ==UserScript==
  2. // @name        Keylol 蓝绿标记修复
  3. // @namespace   https://keylol.com/
  4. // @description 同步 Steam 已购/愿望单,恢复 Keylol 绿/蓝底标记(整合 Steam Info)
  5. // @version     1.2.0
  6. // @match       https://keylol.com/*
  7. // @match       https://steam-tooltip-lite.depar.me/sync
  8. // @grant       GM_getValue
  9. // @grant       GM_setValue
  10. // @grant       GM_xmlhttpRequest
  11. // @connect     steamcommunity.com
  12. // @connect     store.steampowered.com
  13. // @run-at      document-idle
  14. // ==/UserScript==

  15. (function () {
  16.   'use strict';

  17.   var KEY_OWN = 'keylol_fix_own';
  18.   var KEY_WISH = 'keylol_fix_wish';
  19.   var SYNC_HOST = 'steam-tooltip-lite.depar.me';

  20.   function exec(fn) {
  21.     var s = document.createElement('script');
  22.     s.textContent = fn;
  23.     document.body.appendChild(s);
  24.     document.body.removeChild(s);
  25.   }

  26.   function load(url, id) {
  27.     GM_xmlhttpRequest({
  28.       method: 'GET',
  29.       url: url,
  30.       onload: function (r) {
  31.         var data = JSON.stringify(r.responseText).replace(/<\/script/gi, '<\\/script');
  32.         exec('proc_' + id + '(' + data + ')');
  33.       }
  34.     });
  35.   }

  36.   function saveFromStorage(own, wish) {
  37.     GM_setValue(KEY_OWN, own || '[]');
  38.     GM_setValue(KEY_WISH, wish || '[]');
  39.     console.log('[Keylol蓝绿修复] 已保存:own=' + JSON.parse(own || '[]').length +
  40.       ' wish=' + JSON.parse(wish || '[]').length);
  41.   }

  42.   if (location.host === SYNC_HOST) {
  43.     exec('setScriptVersion(' + JSON.stringify(GM_info.script.version) + ')');
  44.     load('https://steamcommunity.com/my/games?tab=all', 'own');
  45.     load('https://store.steampowered.com/dynamicstore/userdata/?_=' +
  46.       Math.floor(Math.random() * 100000), 'userdata');

  47.     var initialLast = localStorage.getItem('last') || '';
  48.     var tries = 0;
  49.     var timer = setInterval(function () {
  50.       tries++;
  51.       var last = localStorage.getItem('last') || '';
  52.       var own = localStorage.getItem('own');
  53.       var wish = localStorage.getItem('wish');
  54.       if (own && (last !== initialLast || tries > 180)) {
  55.         saveFromStorage(own, wish);
  56.         clearInterval(timer);
  57.       } else if (tries > 180) {
  58.         clearInterval(timer);
  59.         console.warn('[Keylol蓝绿修复] 同步未完成');
  60.       }
  61.     }, 500);
  62.     return;
  63.   }

  64.   if (!document.querySelector('script[src*="steam_info.js"]')) {
  65.     var info = document.createElement('script');
  66.     info.src = 'https://' + SYNC_HOST + '/steam_info.js';
  67.     document.body.appendChild(info);
  68.   }

  69.   var STYLE_ID = 'keylol-bluegreen-fix-style';
  70.   function injectStyle() {
  71.     if (document.getElementById(STYLE_ID)) return;
  72.     var s = document.createElement('style');
  73.     s.id = STYLE_ID;
  74.     s.textContent =
  75.       'a.steam-info-link.steam-info-own,a.steam-info-link.steam-info-wish{color:#fff!important}' +
  76.       'a.steam-info-link.steam-info-own{background:#5C8A00!important}' +
  77.       'a.steam-info-link.steam-info-wish{background:#007399!important}';
  78.     (document.head || document.documentElement).appendChild(s);
  79.   }

  80.   var pending = null;
  81.   function apply() {
  82.     var own, wish;
  83.     try {
  84.       own = JSON.parse(GM_getValue(KEY_OWN, '[]') || '[]');
  85.       wish = JSON.parse(GM_getValue(KEY_WISH, '[]') || '[]');
  86.     } catch (e) {
  87.       return;
  88.     }
  89.     if (!own.length && !wish.length) return;

  90.     injectStyle();
  91.     var links = document.querySelectorAll(
  92.       'a[href*="store.steampowered.com/app/"],' +
  93.       'a[href*="store.steampowered.com/sub/"],' +
  94.       'a[href*="store.steampowered.com/bundle/"]'
  95.     );
  96.     var green = 0, blue = 0;
  97.     [].forEach.call(links, function (a) {
  98.       if (a.getAttribute('data-keylol-fix-done')) return;
  99.       var m = String(a.href).match(/\/(?:app|sub|bundle)\/(\d+)/);
  100.       if (!m) return;
  101.       var id = parseInt(m[1], 10);

  102.       var cls = own.indexOf(id) !== -1 ? 'steam-info-own'
  103.         : wish.indexOf(id) !== -1 ? 'steam-info-wish' : null;
  104.       a.setAttribute('data-keylol-fix-done', '1');
  105.       if (!cls) return;

  106.       a.style.color = '';
  107.       a.style.fontWeight = '';
  108.       a.style.backgroundColor = '';
  109.       a.classList.add('steam-info-link', cls);

  110.       var tag = cls === 'steam-info-own' ? '已拥有' : '愿望单';
  111.       var t = a.getAttribute('title') || '';
  112.       if (t.indexOf('[' + tag + ']') === -1) a.setAttribute('title', t + ' [' + tag + ']');
  113.       if (cls === 'steam-info-own') green++; else blue++;
  114.     });
  115.     if (green || blue) console.log('[Keylol蓝绿修复] 绿=' + green + ' 蓝=' + blue);
  116.   }

  117.   function schedule() {
  118.     if (pending) clearTimeout(pending);
  119.     pending = setTimeout(apply, 150);
  120.   }

  121.   apply();
  122.   if (typeof MutationObserver !== 'undefined') {
  123.     new MutationObserver(schedule).observe(document.body, { childList: true, subtree: true });
  124.   }
  125. })();
复制代码

[发帖际遇]: 147406 原价购入的游戏在几天后入包,补偿体力 1 点 幸运榜 / 衰神榜
回复

使用道具 举报

浏览本版块需要:
1. 初阶会员或更高等级;
2. (点击此处)绑定Steam账号
您需要登录后才可以回帖 登录 | 注册

本版积分规则

欢迎发帖参与讨论 o(*≧▽≦)ツ,请注意
1. 寻求帮助或答案的帖子请发到问题互助版块,悬赏有助于问题解决的速度。发错可能失去在该板块发布主题的权限(了解更多)
2. 表达观点可以,也请务必注意语气和用词,以免影响他人浏览,特别是针对其他会员的内容。如觉得违规可使用举报功能 交由管理人员处理,请勿引用对方的内容。
3. 开箱晒物,交易中心,游戏互鉴和福利放送版块请注意额外的置顶版规。
4. 除了提问帖和交易帖以外,不确认发在哪个版块的帖子可以先发在谈天说地。

  作为民间站点,自 2004 年起为广大中文 Steam 用户提供技术支持与讨论空间。历经二十余载风雨,如今已发展为国内最大的正版玩家据点。

列表模式 · · 微博 · Bilibili频道 · Steam 群组 · 贴吧 · QQ群 
Keylol 其乐 ©2004-2026 Chinese Steam User Fan Site.
Designed by Lee in Balestier, Powered by Discuz!
推荐使用 Chrome 或 Microsoft Edge 来浏览本站
广告投放|手机版|广州数趣信息科技有限公司 版权所有|其乐 Keylol ( 粤ICP备17068105号 )
GMT+8, 2026-11-26 13:29
快速回复 返回顶部 返回列表