Create a gist now

Instantly share code, notes, and snippets.

@w33ble /dbprune.js
Last active Aug 18, 2017

What would you like to do?
Pruning Dickbars - Bookmarklet Code
// version 4-2017.18
(function dbprune() {
// restore page scrolling
var body = document.body;
var html = body.parentElement;
body.style['overflow'] = body.style['overflow-y'] = 'auto';
html.style['overflow'] = html.style['overflow-y'] = 'auto';
// check if this is a mobile display
var mHeight = 680;
var mh = window.innerHeight;
var isMobile = mh <= mHeight;
// remove dickbars
var i, elements = document.querySelectorAll('body *');
for (i = 0; i < elements.length; i++) {
var c = getComputedStyle(elements[i]);
var h = Number(c.height.replace('px', ''));
var isFixed = ['fixed', 'sticky', '-webkit-sticky'].indexOf(c.position) >= 0;
var tooTall = (h >= mHeight*3 || h === mh) && c.position === 'absolute';
if (isFixed || (isMobile && tooTall)) {
elements[i].parentNode.removeChild(elements[i]);
}
}
})();
javascript:!function(){var e=document.body,o=e.parentElement;e.style.overflow=e.style["overflow-y"]="auto",o.style.overflow=o.style["overflow-y"]="auto";var t,l=window.innerHeight,r=l<=680,i=document.querySelectorAll("body *");for(t=0;t<i.length;t++){var n=getComputedStyle(i[t]),y=Number(n.height.replace("px","")),d=["fixed","sticky","-webkit-sticky"].indexOf(n.position)>=0,a=(y>=2040||y===l)&&"absolute"===n.position;(d||r&&a)&&i[t].parentNode.removeChild(i[t])}}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment