I find elements on a web page that have been positioned fixed to be in my way frequently. I’d like to find a way to disable position: fixed CSS rules in any web site that I visit.
I wrote a userscript (Firefox, Greasemonkey) that scans every node in the document and figures out if it has a computed style position fixed, then overrides that to be static.
Is there a better way to accomplish my goal?
This is the script I wrote, I’ve narrowed it to just divs for now:
Array.forEach(
document.querySelectorAll("div")
,function(el) {
if (window.getComputedStyle(el).position === 'fixed') {
el.style.position = 'static';
}
}
);
If your Greasemonkey script works, it is probably the most cost effective way to eliminate fixed-positioned styling.
Some alternatives that require much more effort but will use less CPU/memory per page:
Write an Add-on that:
position: fixed.Fork and compile your own version of Firefox that ignores
position: fixed. You’d probably want this controlled by both a “blacklist” and a “whitelist”.