您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
为JAV Library论坛帖子添加已读标记功能
// ==UserScript== // @name jav已读标记 // @version 1.0.0 // @namespace https://sleazyfork.org/zh-CN/users/1461640-%E6%98%9F%E5%AE%BF%E8%80%81%E9%AD%94 // @author 星宿老魔 // @description 为JAV Library论坛帖子添加已读标记功能 // @match *://www.javlibrary.com/cn/publicgroupsearch.php* // @match *://www.javlibrary.com/cn/publictopic.php* // @icon https://www.google.com/s2/favicons?sz=64&domain=javlibrary.com // @license MIT // @grant GM_setValue // @grant GM_getValue // @run-at document-end // ==/UserScript== (function(){"use strict";const CONFIG={STORAGE_KEY:"jav_read_topics",STYLES:{READ_TOPIC:{opacity:"0.6", background:"#f0f0f0",color:"#888"},READ_BADGE:{color:"#666",fontSize:"12px",marginLeft:"8px",fontWeight:"normal"}}, SELECTORS:{topicTable:"table.pubgroup",topicRows:"table.pubgroup tbody tr:not(#header)", topicLinks:'a.topictitle[href*="publictopic.php"]',topicTitleCell:"td.left"},REGEX:{topicId:/publictopic\.php\?id=(\d+)/ },TEXT:{readBadge:"[已读]"}};function extractTopicId(t){const e=t.match(CONFIG.REGEX.topicId);return e?e[1]:null} function getReadTopics(){try{const t=GM_getValue(CONFIG.STORAGE_KEY,[]);return new Set(t)}catch(t){void 0;return new Set }}function saveReadTopics(t){try{GM_setValue(CONFIG.STORAGE_KEY,Array.from(t))}catch(e){void 0}} function markTopicAsRead(t){const e=getReadTopics();e.add(t);saveReadTopics(e)}function isTopicRead(t){ const e=getReadTopics();return e.has(t)}class ReadMarkManager{constructor(){this.readTopics=getReadTopics()}init(){ void 0;if("loading"===document.readyState)document.addEventListener("DOMContentLoaded",()=>{this.handleCurrentPage() });else this.handleCurrentPage()}handleCurrentPage(){const t=window.location.href ;if(t.includes("publicgroupsearch.php")){this.setupReadMarks();this.bindEvents() }else if(t.includes("publictopic.php"))this.markCurrentTopicAsRead()}markCurrentTopicAsRead(){ const t=window.location.href;const e=extractTopicId(t);if(e){this.markAsRead(e);void 0}}setupReadMarks(){ const t=document.querySelectorAll(CONFIG.SELECTORS.topicLinks);t.forEach(t=>{const e=t;e.target="_blank" ;e.rel="noopener noreferrer";const i=extractTopicId(e.href);if(i&&this.isRead(i))this.markAsReadVisually(e)});void 0} bindEvents(){const t=["click","auxclick","mousedown","mouseup","contextmenu"];t.forEach(t=>{ document.addEventListener(t,t=>{const e=t.target;const i=e.closest(CONFIG.SELECTORS.topicLinks);if(i){ const e=extractTopicId(i.href);if(e){this.markAsRead(e);this.markAsReadVisually(i);const o=this.getClickType(t);void 0}} })});document.addEventListener("focusin",t=>{const e=t.target;const i=e.closest(CONFIG.SELECTORS.topicLinks);if(i){ const t=extractTopicId(i.href);if(t){this.markAsRead(t);this.markAsReadVisually(i);void 0}}})}getClickType(t){ if("contextmenu"===t.type)return"右键菜单";if(1===t.button)return"中键点击";if(t.ctrlKey)return"Ctrl+左键点击" ;if(t.metaKey)return"Cmd+左键点击";if(t.shiftKey)return"Shift+左键点击";return"普通左键点击"}markAsRead(t){if(!this.isRead(t)){ this.readTopics.add(t);markTopicAsRead(t);void 0}}isRead(t){return this.readTopics.has(t)||isTopicRead(t)} markAsReadVisually(t){if("true"===t.dataset.readMarked)return;t.dataset.readMarked="true" ;const e=document.createElement("span");e.textContent=CONFIG.TEXT.readBadge;e.style.color=CONFIG.STYLES.READ_BADGE.color ;e.style.fontSize=CONFIG.STYLES.READ_BADGE.fontSize;e.style.marginLeft=CONFIG.STYLES.READ_BADGE.marginLeft ;e.style.fontWeight=CONFIG.STYLES.READ_BADGE.fontWeight;t.appendChild(e);const i=t.closest("tr");if(i){ i.style.opacity=CONFIG.STYLES.READ_TOPIC.opacity;i.style.background=CONFIG.STYLES.READ_TOPIC.background ;i.style.color=CONFIG.STYLES.READ_TOPIC.color}}}const t=new ReadMarkManager;t.init()})();