B站愚人节去绿字
function youzhi(exp) { if (!exp && typeof exp != "undefined" && exp != 0) { //alert(“is null”); return false; } if (typeof exp == "undefined") { // alert("undefined"); return false; } return true; } function rollhtml() { console.log("我被执行了" + Date().toLocaleString()); var map = {}; var map_num = 0; //采用递归调用的方法,比较方便和简单。 function fds(node) { if (node.nodeType === 1) { map_num++; // node.id = "id" + map_num.toLocaleString(); //给节点设置ID let x9 = " classid" + map_num.toLocaleString(); //给节点增加class if (node.className.toLocaleString().indexOf(x9) == -1) { node.className = node.className + x9; // console.log("已经存在class",x9) } } //获取该元素节点的所有子节点 var children = node.childNodes; for (var i = 0; i < children.length; i++) { //递归调用 fds(children[i]); } } fds(document); var nodes_arry = ["A", "DIV", "SPAN", "a", "div", "span"]; for (i = 1; i <= map_num; i++) { let tempid1 = "classid" + i.toLocaleString(); //let el = document.getElementById(tempid1); let el = document.getElementsByClassName(tempid1)[0]; if (youzhi(el)) { // console.log(el) let node_temp = el.nodeName.toLocaleString(); if (youzhi(node_temp)) { // console.log(node_temp) if (nodes_arry.includes(node_temp, 0)) { el.style.color = "black"; } } } } } //document.onmousewheel = rollhtml 一直执行CPU占用太高 rollhtml(); var canRun = true; document.onscroll = function () { if (!canRun) { // 判断是否已空闲,如果在执行中,则直接return return; } canRun = false; setTimeout(function () { console.log("函数节流"); rollhtml(); canRun = true; }, 1000); };
-- the end --
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!