您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
遍历CSS选择器为“p > a”的元素并将不含lemma-id属性元素在当前页面高亮显示其innerText文本
// ==UserScript== // @name 百度废弃词条 // @namespace http://tampermonkey.net/ // @version 0.5 // @description 遍历CSS选择器为“p > a”的元素并将不含lemma-id属性元素在当前页面高亮显示其innerText文本 // @author Leo // @match https://baike.baidu.com/editor* // @match https://baike.baidu.com/wikitask* // @icon https://www.google.com/s2/favicons?sz=64&domain=baidu.com // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; function highlightElements() { // 获取所有匹配选择器的元素 var elements = document.querySelectorAll('p > a'); // 遍历元素并检查是否缺少lemma-id属性 elements.forEach(element => { if (!element.hasAttribute('data-lemmaid')) { // 高亮显示元素的innerText文本 element.style.backgroundColor = 'yellow'; } }); elements = document.querySelectorAll('a[data-lemma-id="0"]'); // 遍历元素并检查是否缺少lemma-id属性 elements.forEach(element => { if(element.attributes["data-lemma-id"].value == '0') { element.style.backgroundColor = 'yellow'; } }); } setInterval(highlightElements, 3000); })();