Created
October 17, 2023 17:46
-
-
Save reggi/5728127e0e3d9e38ff4bfffc6d8c3bf9 to your computer and use it in GitHub Desktop.
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 mastodon-bigger-input-box | |
// @version 1.0.0 | |
// @description Modify the CSS of a specific element on page load | |
// @author Thomas Reggi | |
// @match https://indieweb.social/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
const targetSelector = "#mastodon > div > div > div.columns-area__panels > div.columns-area__panels__pane.columns-area__panels__pane--compositional > div > div > form > div.compose-form__highlightable > div.compose-form__autosuggest-wrapper > div.autosuggest-textarea > label > textarea"; | |
const targetElement = document.querySelector(targetSelector); | |
const applyStyles = (targetElement) => { | |
targetElement.style.setProperty('height', '500px', 'important'); | |
targetElement.style.setProperty('max-height', '40vh', 'important'); | |
}; | |
const observeChanges = () => { | |
// Setting up the mutation observer | |
const observer = new MutationObserver((mutations) => { | |
for (const mutation of mutations) { | |
if (mutation.type === 'attributes' && mutation.attributeName === 'style') { | |
applyStyles(targetElement); | |
} | |
} | |
}); | |
// Starting the observation | |
observer.observe(targetElement, { | |
attributes: true, | |
attributeFilter: ['style'] | |
}); | |
}; | |
applyStyles(targetElement); | |
observeChanges() | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment