liblib comfyUI cmd+, 打开设置,然后 opt + w 切换到浅色模式 , opt + b 切换到深色模式
// ==UserScript==
// @name liblib comfyUI 打开设置面板后,快捷键切换深色浅色。
// @namespace http://leizingyiu.net/
// @version 20250508
// @description liblib comfyUI cmd+, 打开设置,然后 opt + w 切换到浅色模式 , opt + b 切换到深色模式
// @author leizingyiu
// @match http*://comfy.liblib.art/*
// @grant none
// @license GNU AGPLv3
// ==/UserScript==
(function () {
"use strict";
function sequentialClickAndWait(...selectors) {
let delay = Math.floor(Math.random() * 1000);
if (selectors.length > 0) {
const last = selectors[selectors.length - 1];
if (!isNaN(Number(last))) {
delay = Number(last);
selectors.pop();
}
}
function clickNext(index) {
if (index >= selectors.length) {
console.log("全部完成");
return;
}
const selector = selectors[index];
if (selector == null) {
console.log(`第 ${index} 个 selector 是 null,跳过`);
clickNext(index + 1);
return;
}
const el = document.querySelector(selector);
if (el) {
console.log(`点击第 ${index} 个: ${selector}`);
el.click();
} else {
console.warn(`第 ${index} 个 selector 没找到: ${selector}`);
}
setTimeout(() => {
clickNext(index + 1);
}, delay);
}
clickNext(0);
}
document.addEventListener("keydown", function (event) {
if (event.altKey && event.code === "KeyW") {
sequentialClickAndWait(
".p-listbox-list li:nth-child(3)",
"div.p-message-content>div>div>div>div>span",
".p-select-list>li:nth-child(2)",
);
}
if (event.altKey && event.code === "KeyB") {
sequentialClickAndWait(
".p-listbox-list li:nth-child(3)",
"div.p-message-content>div>div>div>div>span",
".p-select-list>li:nth-child(1)",
);
}
});
})();