Skip to content

Instantly share code, notes, and snippets.

@PhilippeVay
Created April 1, 2024 16:00
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 PhilippeVay/d73ad273aac1a8a7eeed0b1720c268fe to your computer and use it in GitHub Desktop.
Save PhilippeVay/d73ad273aac1a8a7eeed0b1720c268fe to your computer and use it in GitHub Desktop.
Readable code of "Isolate images" bookmarklet (from A11y Tools, author Lloydi)
// Bookmarklet "Isolate images" (unescaped and beautified code below)
// It's part of many other (stellar) bookmarklets "A11y Tools"
// Author: Lloydi
// Source: https://a11y-tools.com/bookmarklets/#isolateimages
(function () {
'use strict'
function isolateImages() {
const els = document.querySelectorAll('*');
const page = document.querySelector('body');
console.log("els.length", els.length);
Array.from(els).forEach(function (el) {
el.style.color = "transparent";
el.style.background = "transparent";
el.style.borderColor = "transparent";
el.style.outline = "transparent";
el.style.fontSize = "1px";
});
page.style.zoom = "50%";
const imgs = document.querySelectorAll('img,[role=img]');
Array.from(imgs).forEach(function (img) {
img.style.outline = "10px solid black";
img.style.outlineOffset = "-10px";
});
}
isolateImages();
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment