Created
August 18, 2018 07:35
-
-
Save Lewiscowles1986/48e9f69967e4b09e010a238bff781055 to your computer and use it in GitHub Desktop.
Destroy sticky headers
This file contains 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
/* | |
* Find sticky header elements annoying? Well delete them with this | |
* | |
* inspired by https://www.ghacks.net/2018/08/16/remove-anything-that-is-sticky-on-websites/ | |
* improved (IE9, all recent chrome, mozilla, mobile browsers) using information from: | |
* | |
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes | |
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf | |
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach | |
* - https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle | |
* - https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll | |
* | |
*/ | |
[].slice.call(document.body.querySelectorAll('*')).forEach(function(element) { | |
if (["sticky", "fixed"].indexOf(getComputedStyle(element).position) >= 0) { | |
element.parentNode.removeChild(element); | |
} | |
}); |
This file contains 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
javascript:(function () { | |
var i, elements = document.querySelectorAll('body *'); | |
for (i = 0; i < elements.length; i++) { | |
if (["sticky", "fixed"].includes(getComputedStyle(elements[i]).position)) { | |
elements[i].parentNode.removeChild(elements[i]); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment