// ==UserScript== // @name [MWI]Marketplace Panel Button Disabler // @name:zh-CN [银河奶牛]市场面板按钮禁用器 // @namespace https://cnb.cool/shenhuanjie/skyner-cn/tamper-monkey-script/mwi-orderbook-button-disabler // @version 3.0.0 // @description Disable and gray out buttons in marketplace panels using pure CSS with configurable panel class names // @description:zh-CN 使用纯CSS和可配置的面板类名禁用并灰化市场面板中的按钮 // @author shenhuanjie // @license MIT // @match https://www.milkywayidle.com/game* // @icon https://www.milkywayidle.com/favicon.svg // @grant none // @homepage https://cnb.cool/shenhuanjie/skyner-cn/tamper-monkey-script/mwi-orderbook-button-disabler // @supportURL https://cnb.cool/shenhuanjie/skyner-cn/tamper-monkey-script/mwi-orderbook-button-disabler // @run-at document-start // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 配置对象,包含需要禁用按钮的面板类名 const config = { panelClassNames: [ "MarketplacePanel_orderBook", "MarketplacePanel_itemSummary" ], // 可以在此处添加更多配置项 }; // 生成CSS选择器的函数 function generateCSS(classNames) { // 生成基本选择器 const baseSelectors = classNames.map(className => `div[class*="${className}"] button` ).join(',\n '); // 生成hover、active和focus状态的选择器 const stateSelectors = classNames.flatMap(className => [ `div[class*="${className}"] button:hover`, `div[class*="${className}"] button:active`, `div[class*="${className}"] button:focus` ]).join(',\n '); // 返回完整的CSS return ` /* 选择配置的面板中的所有按钮 */ ${baseSelectors} { opacity: 0.5 !important; cursor: not-allowed !important; pointer-events: none !important; background-color: #e0e0e0 !important; color: #888 !important; border-color: #ccc !important; filter: grayscale(100%) !important; transition: all 0.3s ease !important; } /* 确保禁用状态不会被其他样式覆盖 */ ${stateSelectors} { opacity: 0.5 !important; cursor: not-allowed !important; pointer-events: none !important; background-color: #e0e0e0 !important; color: #888 !important; border-color: #ccc !important; filter: grayscale(100%) !important; box-shadow: none !important; transform: none !important; }`; } // 添加纯CSS实现 const style = document.createElement('style'); style.textContent = generateCSS(config.panelClassNames); document.head.appendChild(style); console.log(`[MarketplacePanelDisabler] 已应用纯CSS禁用规则,面板类名: ${config.panelClassNames.join(', ')}`); })();