Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The first bookmark on my bookmark bar is "Kill floater", and it removes most floating elements on the page. It even works on many sites that hide the page behind a popup. Use it on my iPad all the time.

The bookmarklet:

  javascript:(function()%7B(function%20()%20%7Bvar%20i%2C%20elements%20%3D%20document.querySelectorAll('body%20*')%3Bfor%20(i%20%3D%200%3B%20i%20%3C%20elements.length%3B%20i%2B%2B)%20%7Bif%20(getComputedStyle(elements%5Bi%5D).position%20%3D%3D%3D%20'fixed')%20%7Belements%5Bi%5D.parentNode.removeChild(elements%5Bi%5D)%3B%7D%7D%7D)()%7D)()



I cleaned up and improved this a little. Now it hides the fixed elements, unless their computed top is at 0px. Also makes the body to scroll automatically, as many sites set their body to fixed before the fixed popup is gone:

``` javascript:(function () { var i, elements = document.querySelectorAll('body *'); var style;

    document.body.style.overflow-y = 'auto'
    for (i = 0; i < elements.length; i++) {
        style = getComputedStyle(elements[i]);
        if (style.position === 'fixed' && style.top !== "0px") {
            elements[i].style.display = 'none';
        }
    }
})() ```


This is great, thank you! More precise and thorough then what I had. I'll minify it and start using it on my iPad.


HN breaks the formatting, and does not seem to support Markdown.


Thanks! This will save me a lot of time.


Do you mind prepending the bookmarklet code with two spaces as described here: https://news.ycombinator.com/formatdoc

It's breaking the layout of this entire comment thread for me so I have to scroll horizontally to read all of the comments. Thanks!


I've added two spaces there.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: