Skip to content

Instantly share code, notes, and snippets.

@BriSeven
Created March 10, 2021 05:07
Show Gist options
  • Save BriSeven/03ffd9afd998cfea89a6cd9f36dd243a to your computer and use it in GitHub Desktop.
Save BriSeven/03ffd9afd998cfea89a6cd9f36dd243a to your computer and use it in GitHub Desktop.
get rid of popovers userscript
// ==UserScript==
// @name kill overlays
// @description This is your new file, start writing code
// @match *://*.*
// ==/UserScript==
let style = document.createElement('STYLE');
style.textContent=`
div.hideZ.hideZ.hideZ * {
display: none !important;
}
div.hideZ.hideZ.hideZ::before {
content: attr(class);
color:black;
padding-left: 50px;
position: relative;
display:block;
left:0;
top:0;
}
.hideZ.hideZ.hideZ {
pointer-events: initial !important;
height: 50px !important;
padding: 0;
overflow: hidden !important;
left: 0 !important;
top: 0 !important;
position: static !important;
transform: none !important;
-webkit-transform: none !important;
display: block !important;
background: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMTAgMjEwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCAyMTAgMjEwIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBzdHlsZT0iZmlsbDojMDIwMjAyIiBkPSJtMzQuNzc0IDE1Mi41MDkgMjYuNDQxIDI2LjQ0MiAxOS45MyAxOS45MzFMMy43MjQgMjEwbDExLjExOS03Ny40MjIgMTkuOTMxIDE5LjkzMXptMTQwLjQ1MiAwLTMwLjQ0NS0zMC40NDEtMjYuNDQgMjYuNDM5IDMwLjQ0MSAzMC40NDQtMTkuOTMgMTkuOTMxTDIwNi4yNzYgMjEwbC0xMS4xMTktNzcuNDIyLTE5LjkzMSAxOS45MzF6TTY1LjIyIDEyMi4wNjdsMjYuNDM5IDI2LjQzOS0zMC40NDMgMzAuNDQ0LTI2LjQ0MS0yNi40NDIgMzAuNDQ1LTMwLjQ0MXptLTQuMDA0LTkxLjAxOCAzMC40NDMgMzAuNDQ0LTI2LjQzOSAyNi40NC0zMC40NDYtMzAuNDQyLTE5LjkzMSAxOS45MzFMMy43MjQgMGw3Ny40MjIgMTEuMTE4LTE5LjkzIDE5LjkzMXptNTcuMTI1IDMwLjQ0NCAzMC40NDEtMzAuNDQ0LTE5LjkzLTE5LjkzMUwyMDYuMjc2IDBsLTExLjExOSA3Ny40MjItMTkuOTMyLTE5LjkzMS0zMC40NDUgMzAuNDQyLTI2LjQzOS0yNi40NHoiLz48L3N2Zz4=) no-repeat !important;
color: transparent;
}
iframe.hideZ.hideZ.hideZ {
width: auto !important;
padding-left: 50px;
}
`;
document.body.appendChild(style);
function hidePopovers () {
[...document.querySelectorAll("div:not(.hideZ,.showZ), iframe:not(.hideZ,showZ)")]
.filter( x => {
let z = parseInt(window.getComputedStyle(x).zIndex, 10);
let width = parseInt(window.getComputedStyle(x).width,10);
let height = parseInt(window.getComputedStyle(x).height,10);
let position = window.getComputedStyle(x).position;
let display = window.getComputedStyle(x).display;
let windowarea = window.innerWidth*window.innerHeight;
let condition = (width*height>windowarea*0.2 && (z < 0 || z > 10)) ||
position==="sticky" ||
( width*height < 100 && !!x.src ) ||
( display === 'none' && !!x.src )
if( condition ) {
console.log('popover hiding',z,width,height,position,x.className,x.src);
}
return condition;
})
.forEach( (x, i) => {
if(!(/hideZ/.test(x.className))){
x.className +=" hideZ";
let src = x.src;
if(src) {
x.src='data:text,'+encodeURIComponent(src);
}
x.addEventListener('click',function expand(){
x.className = x.className.replace(" hideZ"," showZ");
x.removeEventListener('click',expand);
x.src=src;
},false);
}
})
}
hidePopovers();
window.addEventListener('load',hidePopovers,false);
document.addEventListener('DOMContentLoaded',hidePopovers,false);
setTimeout(hidePopovers,1000);
setInterval(hidePopovers,30000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment