Skip to content

Instantly share code, notes, and snippets.

@fishyer
Created October 14, 2023 13:47
Show Gist options
  • Save fishyer/165bdfe8b067bd19f8abc90a5c261b4c to your computer and use it in GitHub Desktop.
Save fishyer/165bdfe8b067bd19f8abc90a5c261b4c to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name 监听网页元素-五彩标注
// @namespace your-namespace
// @version 1.0
// @description 当匹配到以后,就修改五彩标注的样式
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
const observer = new MutationObserver((mutations, observer) => {
mutations.forEach(mutation => {
if (mutation.type === 'childList') {
for (const addedNode of mutation.addedNodes) {
if (addedNode instanceof HTMLElement && addedNode.id === 'wuCaiPN6-defaultColor-button-id') {
const childElement = addedNode.querySelector('.wuCaiPN6-small-color-point');
if (childElement) {
childElement.style.marginTop = '0';
childElement.style.width = '60px';
childElement.style.height = '60px';
}
}
}
}
});
});
observer.observe(document.documentElement, { childList: true, subtree: true,attributes: true, attributeFilter: ['style'] });
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment