Skip to content

Instantly share code, notes, and snippets.

@cmdr2
Last active August 6, 2026 10:23
Show Gist options
  • Select an option

  • Save cmdr2/932efff29e9ddbd58378c32ba13706a8 to your computer and use it in GitHub Desktop.

Select an option

Save cmdr2/932efff29e9ddbd58378c32ba13706a8 to your computer and use it in GitHub Desktop.
focus-columns-image-popup.js
javascript:(function(){var d=document;var elms=d.querySelectorAll('style,link[rel="stylesheet"]');for(var i=0;i<elms.length;i++){elms[i].parentNode.removeChild(elms[i]);}var s=d.createElement('style');s.innerHTML='* { background: #181a1b !important; color: rgb(232, 230, 227) !important; font-family: monospace !important; font-size: 12pt !important; line-height: 1.4 !important; border: none !important; } body { column-count: 3 !important; column-gap: 40px !important; max-width: 100% !important; margin: 0 auto !important; padding: 40px !important; h1, h2, h3 { column-span: all !important; display: inline; } } a { color: rgb(232, 230, 227) !important; text-decoration: underline !important; } a:visited { color: rgb(232, 230, 227) !important; } img, svg, canvas { filter: invert(1) hue-rotate(180deg) opacity(0.6) !important; max-width: 100% !important; height: auto !important; cursor: pointer !important; }';d.head.appendChild(s);d.querySelectorAll('img, svg, canvas').forEach(function(el){el.onclick=function(e){e.stopPropagation();e.preventDefault();var lb=d.createElement('div');lb.setAttribute('style','position:fixed!important;top:0!important;left:0!important;width:100vw!important;height:100vh!important;background:rgba(0,0,0,0.9)!important;z-index:999999!important;display:flex!important;align-items:center!important;justify-content:center!important;');var lbi=d.createElement('img');lbi.setAttribute('style','max-width:95%!important;max-height:95%!important;object-fit:contain!important;filter:none!important;background:transparent!important;');if(el.tagName==='IMG'){lbi.src=el.src;}else if(el.tagName==='CANVAS'){lbi.src=el.toDataURL();}else{lbi.src='data:image/svg+xml;utf8,'+encodeURIComponent(el.outerHTML);}lb.appendChild(lbi);lb.onclick=function(le){le.stopPropagation();lb.remove();d.documentElement.style.setProperty('overflow','auto','important');d.body.style.setProperty('overflow','auto','important');d.body.style.setProperty('position','static','important');window.focus();d.body.focus();};d.body.appendChild(lb);};});})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment