mirror of
https://gitee.com/butubb8/blowfish.git
synced 2025-12-05 14:17:50 +08:00
fix(a11y): prevent disableImages FOUC
This commit is contained in:
@@ -144,7 +144,10 @@ window.A11yPanel = (() => {
|
||||
};
|
||||
|
||||
if (getSettings().disableImages) {
|
||||
FEATURES.disableImages.apply(true);
|
||||
new MutationObserver(() => {
|
||||
const img = document.getElementById("background-image");
|
||||
if (img) img.style.display = "none";
|
||||
}).observe(document, { childList: true, subtree: true });
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
|
||||
@@ -37,16 +37,3 @@ document.querySelectorAll("script[data-target-id]").forEach((script) => {
|
||||
const disableBlur = settings.disableBlur || false;
|
||||
setBackgroundBlur(targetId, scrollDivisor, disableBlur, isMenuBlur);
|
||||
});
|
||||
|
||||
// Prevent disableImages FOUC
|
||||
// Note: I tried putting this in a11y.js but it did not work, and placing it here prevents FOUC
|
||||
(() => {
|
||||
const settings = JSON.parse(localStorage.getItem("a11ySettings") || "{}");
|
||||
if (settings.disableImages) {
|
||||
document.querySelectorAll("script[data-image-id]").forEach((script) => {
|
||||
const imageId = script.getAttribute("data-image-id");
|
||||
const image = imageId && document.getElementById(imageId);
|
||||
if (image) image.style.display = "none";
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user