Skip to content

Instantly share code, notes, and snippets.

@reggi
Created October 17, 2023 17:46
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 reggi/5728127e0e3d9e38ff4bfffc6d8c3bf9 to your computer and use it in GitHub Desktop.
Save reggi/5728127e0e3d9e38ff4bfffc6d8c3bf9 to your computer and use it in GitHub Desktop.
// ==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