Skip to content

Instantly share code, notes, and snippets.

@Lewiscowles1986
Created August 18, 2018 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lewiscowles1986/48e9f69967e4b09e010a238bff781055 to your computer and use it in GitHub Desktop.
Save Lewiscowles1986/48e9f69967e4b09e010a238bff781055 to your computer and use it in GitHub Desktop.
Destroy sticky headers
/*
* 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);
}
});
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