Skip to content

Instantly share code, notes, and snippets.

@KiitoX
Created June 10, 2019 12:24
Show Gist options
  • Select an option

  • Save KiitoX/cca9c1d5ecd08de1c8f41638825882e0 to your computer and use it in GitHub Desktop.

Select an option

Save KiitoX/cca9c1d5ecd08de1c8f41638825882e0 to your computer and use it in GitHub Desktop.
Mastodon fix height of Getting Started column
// ==UserScript==
// @name Mastodon height fix
// @namespace https://gist.github.com/KiitoX/cca9c1d5ecd08de1c8f41638825882e0
// @version 0.1
// @description adjust the height for the getting started column after it's added
// @author KiitoX
// @match https://niu.moe/web/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
let setHeight = (elem) => {
elem.style.height = "-webkit-fill-available";
if(elem.offsetHeight < 10) {
elem.style.height = "initial";
window.setTimeout(() => setHeight(elem), 2);
}
};
let observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (!mutation.addedNodes) return
for (let i = 0; i < mutation.addedNodes.length; i++) {
// do things to your newly added nodes here
let node = mutation.addedNodes[i];
let elem = node.querySelector(".getting-started");
if (elem) {
setHeight(elem);
}
}
});
});
observer.observe(document.body, {
childList: true,
subtree: true,
attributes: true,
characterData: false,
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment