Kill Sticky Headers

Posted on: 27th October 2018


Here is the slightly modified code of the original Kill Sticky by Alisdair McDiarmid — all credit should go to him.
If you add this bookmarklet to your bookmark bar you can then click it whenever you’re on a site with annoying sticky/fixed elements (typically menu bars).

Kill Sticky - Drag this to Bookmark bar

If you’re using a browser that doesn’t allow dragging to the bookmark bar, you can manually create a new bookmark that has the following address (including the word javascript at the beginning):

javascript:(function()%7B(function()%20%7Bvar%20i%2Cels%20%3D%20document.querySelectorAll(%22body%20*%22)%3Bfor%20(i%20%3D%200%3B%20i%20%3C%20els.length%3B%20i%2B%2B)%20%7Bif%20(getComputedStyle(els%5Bi%5D).position%20%3D%3D%3D%20%22sticky%22%20%7C%7C%20getComputedStyle(els%5Bi%5D).position%20%3D%3D%3D%20%22fixed%22)%20%7Bels%5Bi%5D.parentNode.removeChild(els%5Bi%5D)%3B%7D%7D%7D)()%7D)()
If you’re interested, here is the full code that is being ran by the bookmarklet:
(function() {
var i,els = document.querySelectorAll("body *");
for (i = 0; i < els.length; i++) {
if (getComputedStyle(els[i]).position === "sticky" || getComputedStyle(els[i]).position === "fixed") {
els[i].parentNode.removeChild(els[i]);
}
}
})();

Edit for Android / Brave, please try:

Android/Brave Bookmarklet - Drag This

Or manually edit bookmarklet URL:
javascript:(function()%7Bvar%20i%2Cels%20%3D%20document.querySelectorAll(%22body%20*%22)%3Bfor%20(i%20%3D%200%3B%20i%20%3C%20els.length%3B%20i%2B%2B)%20%7Bif%20(getComputedStyle(els%5Bi%5D).position%20%3D%3D%3D%20%22sticky%22%20%7C%7C%20getComputedStyle(els%5Bi%5D).position%20%3D%3D%3D%20%22fixed%22)%20%7Bels%5Bi%5D.style.position%3D'static'%3B%7D%7D%7D)()

Written By: MrWigster