Skip to content

Instantly share code, notes, and snippets.

@JAffleck
Last active June 16, 2021 15:55
Show Gist options
  • Save JAffleck/b75b156b3c70725a952f66fa5f927a6c to your computer and use it in GitHub Desktop.
Save JAffleck/b75b156b3c70725a952f66fa5f927a6c to your computer and use it in GitHub Desktop.
(function() {
var CLASS = 'hide-images';
var STYLE = 'html body,html body *,html body *::before,html body *::after { background-image: none !important; } html body img, html body svg, html body video, html body iframe { opacity: 0.02 !important; }';
var block = document.querySelector('.' + CLASS);
// add/remove style block to override images
if (block) block.remove();
else {
block = document.createElement('style');
block.className = CLASS;
block.innerHTML = STYLE;
document.head.appendChild(block);
}
})();
/////////////////////////
// Unfortunately you have to let these load before it will hide them
javascript:(function(){var a="hide-images",b="html body,html body *,html body *::before,html body *::after { background-image: none !important; } html body img, html body video, html body svg, html body iframe { opacity: 0.02 !important; }",c=document.querySelector("."+a);c?c.remove():(c=document.createElement("style"),c.className=a,c.innerHTML=b,document.head.appendChild(c))})()
@JAffleck
Copy link
Author

JAffleck commented Jun 16, 2021

This might be an approach to remove iframes/images
http://dyn-web.com/tutorials/iframes/hidden/

And another approach: (mess with opacity, won't save laptop battery though.)
https://medium.com/@zachcaceres/dont-use-display-none-to-hide-iframes-in-safari-b51715eb22c4

https://blog.logrocket.com/the-ultimate-guide-to-iframes/

// This would remove all img elements (could do same with iframes, maybe do something similar with adding hidden to the element)
https://codepen.io/anthonyLukes/pen/DaGtF

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