// ==UserScript== // @name Kemono 更新標示 (虛擬DOM兼容版) // @name:zh-TW Kemono 更新標示 (虛擬DOM兼容版) // @name:zh-CN Kemono 更新标记 (虚拟DOM兼容版) // @namespace https://greasyfork.org/zh-CN/users/1051751-mark-levi // @version 2.4.0 // @description Kemono post highlighter with virtual DOM support. Force reprocessing on navigation. // @description:zh-TW Kemono更新標示,支援虛擬DOM。導航時強制重新處理。 // @description:zh-CN Kemono更新标记,支援虚拟DOM。导航时强制重新处理。 // @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 https://update.greasyfork.icu/scripts/548796/Kemono%20%E6%9B%B4%E6%96%B0%E6%A8%99%E7%A4%BA%20%28%E8%99%9B%E6%93%ACDOM%E5%85%BC%E5%AE%B9%E7%89%88%29.user.js // @updateURL https://update.greasyfork.icu/scripts/548796/Kemono%20%E6%9B%B4%E6%96%B0%E6%A8%99%E7%A4%BA%20%28%E8%99%9B%E6%93%ACDOM%E5%85%BC%E5%AE%B9%E7%89%88%29.meta.js // ==/UserScript== (function() { 'use strict'; const prefix = '[KemonoCR]'; const log = (...args) => console.log(prefix, ...args); let isProcessing = false; // --- 日期處理函式 --- 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 todayStr = toYMD(today); // 計算天數差的函式 function getDayDiff(dateStr) { try { const postDate = new Date(dateStr); const todayNoTime = new Date(todayStr); const postDateNoTime = new Date(dateStr); const diffTime = todayNoTime - postDateNoTime; const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24)); return Math.max(0, diffDays); } catch (error) { return -1; } } /** * 添加標記到元素 */ function appendLabel(el, text, dayDiff) { // 移除現有的標記(如果存在) const existingLabel = el.querySelector('.kemono-label'); if (existingLabel) { existingLabel.remove(); } const labelSpan = document.createElement('span'); labelSpan.className = 'kemono-label'; labelSpan.textContent = text; labelSpan.style.fontWeight = 'bold'; labelSpan.style.marginLeft = '5px'; if (dayDiff === 0) { labelSpan.style.color = 'red'; } else if (dayDiff === 1) { labelSpan.style.color = 'orange'; } else if (dayDiff === 2) { labelSpan.style.color = 'gold'; } else if (dayDiff === 3) { labelSpan.style.color = 'green'; } else if (dayDiff === 4) { labelSpan.style.color = 'blue'; } else if (dayDiff === 5) { labelSpan.style.color = 'purple'; } else if (dayDiff >= 6) { labelSpan.style.color = '#666666'; } el.appendChild(labelSpan); } /** * 處理單一