// ==UserScript== // @name Kemono.cr 更新標示 (彩色優化版) // @name:zh-TW Kemono.cr 更新標示 (彩色優化版) // @name:zh-CN Kemono.cr 更新标记 (彩色优化版) // @namespace https://greasyfork.org/users/YOUR-USER-ID // <-- 請將 YOUR-USER-ID 換成你的 Greasy Fork 用戶 ID // @version 2.0.0 // @description Highlights recent posts on Kemono with colored labels: "Today" (Red), "Yesterday" (Yellow), and "Day Before" (Green). High-performance and optimized to only process new content, fixing high CPU usage issues. // @description:zh-TW 高效能版本。為「今日/昨日/前日」的更新附加紅/黃/綠色的文字標示,方便快速識別。只處理新載入的內容,避免重複掃描,解決 CPU 佔用過高的問題。 // @description:zh-CN 高性能版本。为“今日/昨日/前日”的更新附加红/黄/绿色的文字标记,方便快速识别。只处理新加载的内容,避免重复扫描,解决 CPU 占用过高的问​​题。 // @author Your Name Here // <-- 請改成你的名字或暱稱 // @match https://kemono.cr/* // @match http://kemono.cr/* // @match https://kemono.su/* // @match http://kemono.su/* // @grant none // @run-at document-idle // @license MIT // @downloadURL none // ==/UserScript== (function() { 'use strict'; const prefix = '[KemonoCR]'; const log = (...args) => console.log(prefix, ...args); // --- 日期與樣式設定 --- const toYMD = (date) => { const y = date.getFullYear(); const m = String(date.getMonth() + 1).padStart(2, '0'); const d = String(date.getDate()).padStart(2, '0'); return `${y}-${m}-${d}`; }; const today = new Date(); const yesterday = new Date(); yesterday.setDate(today.getDate() - 1); const dayBeforeYesterday = new Date(); dayBeforeYesterday.setDate(today.getDate() - 2); // 將日期、文字和顏色映射在一起 const dateMap = { [toYMD(today)]: { text: ' 今日更新', color: 'red' }, [toYMD(yesterday)]: { text: ' 昨天更新', color: 'gold' }, // 使用 gold,比 yellow 在白色背景上更易讀 [toYMD(dayBeforeYesterday)]: { text: ' 前天更新', color: 'green' }, }; log('Date map with colors initialized:', dateMap); /** * 處理單一