Created
April 2, 2024 15:49
-
-
Save LenAnderson/f0b61e246bf3ef49f7ec6417d9f688f1 to your computer and use it in GitHub Desktop.
SillyTavern - Expand ALL The Editors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name SillyTavern - Expand ALL The Editors | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-04-02 | |
// @description CTRL+ALT+Click into any textarea to maximize | |
// @author LenAnderson | |
// @match http://localhost:8000/ | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=undefined.localhost | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function debounce(func, timeout = 300) { | |
let timer; | |
return (...args) => { | |
clearTimeout(timer); | |
timer = setTimeout(() => { func.apply(this, args); }, timeout); | |
}; | |
} | |
const addExpand = ()=>{ | |
const tas = Array.from(document.querySelectorAll('textarea[id]:not([data-editor-maximize])')); | |
for (const ta of tas) { | |
ta.setAttribute('data-editor-maximize', 1); | |
ta.addEventListener('click', evt=>{ | |
if (evt.ctrlKey && evt.altKey && !evt.shiftKey) { | |
const btn = document.createElement('div'); { | |
btn.classList.add('editor_maximize'); | |
btn.setAttribute('data-for', ta.id); | |
btn.style.display= 'none'; | |
ta.insertAdjacentElement('afterend', btn); | |
btn.click(); | |
btn.remove(); | |
} | |
} | |
}); | |
} | |
}; | |
addExpand(); | |
const mo = new MutationObserver(debounce(addExpand)); | |
mo.observe(document.body, {childList:true, subtree:true, attributes:true}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment