I rewrote the script a bit. It fetches the SVG code from the image src
, creates a dummy copy and inserts it as overlay, scrolls to the active occlusion and then removes the dummy again.
/** Auto-scroll for Image Occlusion Enhanced
* @author Matthias Metelka <github.com/kleinerpirat>
*/
(async function () {
const img = document.querySelector("#io-overlay>img");
const file = await fetch(img.src);
const mask = new DOMParser()
.parseFromString(await file.text(), "image/svg+xml")
.querySelector("svg");
mask.removeAttribute("height");
mask.removeAttribute("width");
mask.style.cssText = "position: absolute; top: 0; right: 0; bottom: 0; left: 0;";
img.parentNode.insertBefore(mask, img);
mask.querySelector("rect.qshape").scrollIntoView({
block: "center",
inline: "center",
});
mask.remove();
})();
Of course, you’re free to use or modify it for your add-on!