侦听元素innerHTML变化
当前为
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/470241/1215961/%E4%BE%A6%E5%90%ACinnerHTML.js
// ==UserScript==
// @name 侦听innerHTML
// @namespace https://leochan.me
// @version 1.0.0
// @description 侦听元素innerHTML变化
// @author Leo
// @match *://*
// @icon https://www.google.com/s2/favicons?sz=64&domain=leochan.me
// @licesen GPLv2
// @grant none
// ==/UserScript==
function leoChanWatchInnerHTML(selector, cb){
let targetElement = document.querySelector(selector);
let previousInnerHTML = targetElement.innerHTML;
let timer = null;
targetElement.addEventListener('DOMSubtreeModified', () => {
clearTimeout(timer);
timer = setTimeout(() => {
if (targetElement.innerHTML !== previousInnerHTML) {
cb()
}
previousInnerHTML = targetElement.innerHTML;
}, 100);
});
}
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址