NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name dmsca 高亮标记已修复\已确认\不可用 // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match http://192.168.1.156/Dmca/* // @icon https://www.google.com/s2/favicons?sz=64&domain=1.156 // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // 选中所有表格单元格,并根据内容进行高亮 function highlightCells() { const cellslist = [ document.querySelectorAll('.rgRow td'), document.querySelectorAll('.rgAltRow td') ]; cellslist.forEach(cells =>Array.from(cells).forEach(cell => { // 根据内容匹配要高亮的单元格 if (cell.textContent.includes('不可用')) { const styles = ` background-color: gray; color: white; `; cell.style.cssText = styles; } if (cell.textContent.includes('已确认')) { const styles = ` background-color: green; color: white; `; cell.style.cssText = styles; } if (cell.textContent.includes('未审计')) { const styles = ` background-color: yellow; color: black; `; cell.style.cssText = styles; } }) ); } highlightCells(); // 创建一个 MutationObserver 实例,监听目标节点及其子节点树上的DOM变化 const observer = new MutationObserver(mutationsList => { for (let mutation of mutationsList) { if (mutation.type === 'childList') { // 当内容变化时重新执行上色逻辑 highlightCells(); } } }); // 需要观察变动的目标节点 const targetNode = document.querySelector('body'); // 配置观察选项: const config = { childList: true, subtree: true }; // 传入目标节点和观察选项 observer.observe(targetNode, config); })();