Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LenAnderson/f0b61e246bf3ef49f7ec6417d9f688f1 to your computer and use it in GitHub Desktop.
Save LenAnderson/f0b61e246bf3ef49f7ec6417d9f688f1 to your computer and use it in GitHub Desktop.
SillyTavern - Expand ALL The Editors
// ==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