Skip to content

Instantly share code, notes, and snippets.

@jankapunkt
Last active March 25, 2024 12:01
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 jankapunkt/a442d10a2d3cda905843ca35645007d8 to your computer and use it in GitHub Desktop.
Save jankapunkt/a442d10a2d3cda905843ca35645007d8 to your computer and use it in GitHub Desktop.
dev.to save button space
// ==UserScript==
// @name dev.to save button space
// @version 1
// @grant none
// ==/UserScript==
const BUTTON_STYLE = '200px'
const target = document.querySelector('body')
const callback = (mutationList, observer) => {
for (const mutation of mutationList) {
if (mutation.type === 'childList' && mutation.target.id === 'article-form') {
const actions = mutation.addedNodes[0]
if (actions && actions.id === 'editor-actions') {
Array.from(actions.children)[1].style.marginLeft = BUTTON_STYLE
}
}
}
}
// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback)
// Start observing the target node for configured mutations
observer.observe(target, { attributes: true, childList: true, subtree: true })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment