Skip to content

Instantly share code, notes, and snippets.

@SLAPaper
Last active September 3, 2023 08:09
Show Gist options
  • Save SLAPaper/080f93885dcd7ae8ba414dc5c576652f to your computer and use it in GitHub Desktop.
Save SLAPaper/080f93885dcd7ae8ba414dc5c576652f to your computer and use it in GitHub Desktop.
FIx Lobe Theme in A1111 WebUI v1.6.0RC
// ==UserScript==
// @name A1111 WebUI fix lobe theme
// @namespace http://tampermonkey.net/
// @version 0.3
// @description fix Lobe theme broken webui v1.6.0
// @author SLAPaper, primeinc
// @match http*://localhost:7860/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=undefined.localhost
// @grant none
// ==/UserScript==
function waitForElm(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
observer.disconnect();
resolve(document.querySelector(selector));
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
function patchDOM() {
waitForElm('textarea[data-testid="textbox"][class^="svelte-"]').then((elm) => {
elm.style.color = 'white';
});
waitForElm('.acss-m1wjsb[data-code-type="highlighter"]').then((elm) => {
elm.style.display = 'none';
});
console.log('patchedDOM');
}
function handleTabClick() {
patchDOM();
}
(function() {
'use strict';
// Run initially and every 5 seconds
setInterval(patchDOM, 5000);
// Listen for clicks on the document body with capturing phase
document.body.addEventListener('click', function(e) {
if (e.target && e.target.id === 'rc-tabs-0-tab-tab_img2img') {
handleTabClick();
console.log('img2img clicked');
}
}, true);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment