Create a gist now

Instantly share code, notes, and snippets.

Embed
Kill sticky headers.
(function () {
var i, elements = document.querySelectorAll('body *');
for (i = 0; i < elements.length; i++) {
if (getComputedStyle(elements[i]).position === 'fixed') {
elements[i].parentNode.removeChild(elements[i]);
}
}
})();
@xd1936

This comment has been minimized.

Show comment
Hide comment
@xd1936

xd1936 Jun 27, 2017

for (var i in elements.length) { !
For Each > For.

xd1936 commented Jun 27, 2017

for (var i in elements.length) { !
For Each > For.

@jclark-dot-org

This comment has been minimized.

Show comment
Hide comment
@jclark-dot-org

jclark-dot-org Jun 27, 2017

Brilliant on mobile. Adding a bookmarklet is a bit of a pain on iOS; I used these directions: https://apple.stackexchange.com/a/74208/22536. I had no problem copying the formatted JS text from the article and prefixing it with "javascript:" when editing the bookmark.

Brilliant on mobile. Adding a bookmarklet is a bit of a pain on iOS; I used these directions: https://apple.stackexchange.com/a/74208/22536. I had no problem copying the formatted JS text from the article and prefixing it with "javascript:" when editing the bookmark.

@terwanerik

This comment has been minimized.

Show comment
Hide comment
@terwanerik

terwanerik Jun 27, 2017

elements[i].style.position = 'absolute' isn't that better? So you don't have to refresh the page if your nav was sticky

terwanerik commented Jun 27, 2017

elements[i].style.position = 'absolute' isn't that better? So you don't have to refresh the page if your nav was sticky

@RyanRoberts

This comment has been minimized.

Show comment
Hide comment
@RyanRoberts

RyanRoberts Jun 27, 2017

You might also want to check for position sticky since that has decent support now.

You might also want to check for position sticky since that has decent support now.

@truthdoug

This comment has been minimized.

Show comment
Hide comment
@truthdoug

truthdoug Jun 27, 2017

yes, what @terwanerik said, but I'd suggest 'static' instead of absolute.

yes, what @terwanerik said, but I'd suggest 'static' instead of absolute.

@mgiraldo

This comment has been minimized.

Show comment
Hide comment
@mgiraldo

mgiraldo Aug 2, 2017

extension doesn't work in twitter :\

mgiraldo commented Aug 2, 2017

extension doesn't work in twitter :\

@nborrmann

This comment has been minimized.

Show comment
Hide comment
@nborrmann

nborrmann Aug 22, 2017

This also kills headers that use position: sticky:

    if (["sticky", "fixed"].includes(getComputedStyle(elements[i]).position)) {

(line 5)

nborrmann commented Aug 22, 2017

This also kills headers that use position: sticky:

    if (["sticky", "fixed"].includes(getComputedStyle(elements[i]).position)) {

(line 5)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment