比如拦截 html 标签的 font-size 样式的更改:
... <body> <script> var observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.type === 'attributes' && mutation.attributeName === 'style') { var target = mutation.target; var oldStyle = mutation.oldValue; var newStyle = target.getAttribute('style'); if (target.tagName == "HTML" && newStyle.includes("font-size")) debugger } }); }); var targetNode = document.documentElement; var config = { attributes: true, attributeOldValue: true, attributeFilter: ['style'] }; observer.observe(targetNode, config); </script> ...
标签:style,target,更改,js,html,mutation,var From: https://www.cnblogs.com/nanfei/p/17479556.html