Skip to content

Instantly share code, notes, and snippets.

@johnmellor
Created April 25, 2023 21:50
Show Gist options
  • Save johnmellor/66c22c651e6651a7f74c91b66639a6f1 to your computer and use it in GitHub Desktop.
Save johnmellor/66c22c651e6651a7f74c91b66639a6f1 to your computer and use it in GitHub Desktop.
Bookmarklet to hide fixed position elements and unlock scrolling; good for decluttering websites
javascript:
/* Hide fixed elements and unlock scrolling. */
(()=>{
/* Unlock scrolling. */
for (let el of [document.documentElement, document.body]) {
let cs = getComputedStyle(el);
if (['hidden', 'clip'].includes(cs.overflowY)) el.style.setProperty('overflow', 'visible', 'important');
if (cs.position === 'fixed') el.style.setProperty('position', 'static', 'important');
}
/* Hide fixed position elements. */
for (let el of document.body.querySelectorAll('*')) {
let cs = getComputedStyle(el);
if (cs.position === 'fixed') el.style.setProperty('display', 'none', 'important');
else if (cs.position === 'sticky') el.style.setProperty('position', 'static', 'important');
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment