// ==UserScript== // @name KJL后台-编缉器隐藏网格和高亮隐藏参数 // @namespace Violentmonkey Scripts // @match https://www.kujiale.com/vc/modeleditor/new* // @grant none // @version 1.1 // @author hejie13250 // @description 2025/03/04 16:49:59 // ==/UserScript== // (function() { // 'use strict'; // // 创建一个 MutationObserver 实例 // var observer = new MutationObserver(function(mutationsList, observer) { // // 检查是否有节点被添加 // for (let mutation of mutationsList) { // if (mutation.type === 'childList' && mutation.addedNodes.length > 0) { // // 页面打开后隐藏网格 // let gridButton = document.querySelector('div.tuipro-bottombar-group:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1)'); // if (gridButton) { // gridButton.click(); // let hideGridOption = document.querySelector('li.visibility-menu-content-item:nth-child(1)'); // if (hideGridOption) { // hideGridOption.click(); // gridButton.click(); // } // } // // 页面打开后高亮隐藏变量 // let highlightButton = document.querySelector('button.tui-switch:nth-child(2)'); // if (highlightButton) { // highlightButton.click(); // } // // 停止观察,因为我们已经完成了需要的操作 // observer.disconnect(); // } // } // }); // // 开始观察 body 的变化 // observer.observe(document.body, { childList: true, subtree: true }); // })(); (function() { 'use strict'; // 目标选择器 const gridButtonSelector = 'div.tuipro-bottombar-group:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1)'; const hideGridOptionSelector = 'li.visibility-menu-content-item:nth-child(1)'; const highlightButtonSelector = 'button.tui-switch:nth-child(2)'; const checkButtonSelector = 'button.tui-switch:nth-child(2)'; // 执行操作的函数 function performActions() { // 隐藏网格 let gridButton = document.querySelector(gridButtonSelector); if (gridButton) { gridButton.click(); let hideGridOption = document.querySelector(hideGridOptionSelector); if (hideGridOption) { hideGridOption.click(); gridButton.click(); // 可能是为了关闭菜单? } } else { console.log("未能找到网格按钮"); } // 高亮隐藏变量 let highlightButton = document.querySelector(highlightButtonSelector); if (highlightButton) { highlightButton.click(); } else { console.log("未能找到高亮开关按钮"); } } // 创建一个MutationObserver实例 const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { mutation.addedNodes.forEach((node) => { if (node.nodeType === 1) { // 确保是元素节点 let checkButton = node.querySelector(checkButtonSelector); if (checkButton) { performActions(); observer.disconnect(); // 执行一次后停止观察 } } }); }); }); // 配置观察选项 const config = { childList: true, subtree: true }; // 开始观察整个文档 observer.observe(document.body, config); // 初始检查,以防目标元素已经存在 let checkButton = document.querySelector(checkButtonSelector); if (checkButton) { performActions(); observer.disconnect(); // 如果已经找到,停止观察 } })();