Last active
September 27, 2024 11:26
-
-
Save vbuaraujo/bddb3b93a0b2b7e28e1b to your computer and use it in GitHub Desktop.
GreaseMonkey script to remove "position: fixed" from webpages
This file contains hidden or 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
| // ==UserScript== | |
| // @name unfix-all-the-toolbars | |
| // @description Removes "position: fixed" style from elements, unfixing "toolbars" and the such. | |
| // @namespace http://inf.ufrgs.br/~vbuaraujo/ | |
| // @include * | |
| // @version 1 | |
| // @grant none | |
| // ==/UserScript== | |
| // Based on https://stackoverflow.com/questions/13696100/greasemonkey-script-to-make-fixed-positioned-elements-static | |
| function unfixAll() { | |
| Array.forEach( | |
| document.querySelectorAll("h1, h2, ul, ol, li, div, nav, header, footer"), | |
| function (el) { | |
| var style = window.getComputedStyle(el); | |
| if (style.position === "fixed" && | |
| !(style.display === "none" || style.visibility === "hidden")) | |
| /* Avoid unfixing JavaScript popus like Twitter's "confirm retweet" window */ | |
| { | |
| el.style.position = "static"; | |
| /* I tried using "absolute" in the past, but this breaks WordPress's footer. | |
| Using "static" breaks it too, but at least it doesn't get in the way. */ | |
| } | |
| }); | |
| } | |
| window.addEventListener("load", unfixAll); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment