Created
April 25, 2023 21:50
-
-
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
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
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