accessify-widget 0.2.3 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/accessify.min.js +1 -1
- package/dist/accessify.min.js.map +1 -1
- package/dist/accessify.mjs +1 -1
- package/dist/animation-stop-C6ToNlBr.js +505 -0
- package/dist/animation-stop-C6ToNlBr.js.map +1 -0
- package/dist/hide-images-B_LeCBcd.js +105 -0
- package/dist/hide-images-B_LeCBcd.js.map +1 -0
- package/dist/{index-CsJDqdBW.js → index-eprjFXa3.js} +37 -10
- package/dist/{index-CsJDqdBW.js.map → index-eprjFXa3.js.map} +1 -1
- package/dist/{keyboard-nav-CkAYxUc1.js → keyboard-nav-CAWn30Tw.js} +64 -2
- package/dist/keyboard-nav-CAWn30Tw.js.map +1 -0
- package/dist/{page-structure-yWkBKmwo.js → page-structure-DDjJeVCc.js} +75 -2
- package/dist/page-structure-DDjJeVCc.js.map +1 -0
- package/dist/{text-simplify-C9gzE3t0.js → text-simplify-B1v6Muvn.js} +117 -16
- package/dist/text-simplify-B1v6Muvn.js.map +1 -0
- package/dist/widget.js +1 -1
- package/dist/widget.js.map +1 -1
- package/package.json +2 -2
- package/dist/animation-stop-DXebPS8D.js +0 -88
- package/dist/animation-stop-DXebPS8D.js.map +0 -1
- package/dist/hide-images-DJwmsV2C.js +0 -39
- package/dist/hide-images-DJwmsV2C.js.map +0 -1
- package/dist/keyboard-nav-CkAYxUc1.js.map +0 -1
- package/dist/page-structure-yWkBKmwo.js.map +0 -1
- package/dist/text-simplify-C9gzE3t0.js.map +0 -1
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
function createHideImagesModule() {
|
|
2
|
+
let enabled = false;
|
|
3
|
+
const STYLE_ID = "accessify-hide-images";
|
|
4
|
+
let bgImageOriginals = /* @__PURE__ */ new Map();
|
|
5
|
+
let mutationObserver = null;
|
|
6
|
+
const CSS = `
|
|
7
|
+
/* Standard image elements */
|
|
8
|
+
img, picture, svg:not([aria-hidden="true"]), video, canvas,
|
|
9
|
+
[role="img"], figure {
|
|
10
|
+
opacity: 0 !important;
|
|
11
|
+
pointer-events: none !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* CSS background-images (inline styles) */
|
|
15
|
+
[style*="background-image"] {
|
|
16
|
+
background-image: none !important;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Lazy-load images that haven't loaded yet */
|
|
20
|
+
img[data-src], img[data-lazy-src], img[data-original],
|
|
21
|
+
img[loading="lazy"] {
|
|
22
|
+
opacity: 0 !important;
|
|
23
|
+
pointer-events: none !important;
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
function hideBackgroundImages() {
|
|
27
|
+
const all = document.querySelectorAll("*");
|
|
28
|
+
for (const el of all) {
|
|
29
|
+
if (el.closest("#accessify-root")) continue;
|
|
30
|
+
const computed = getComputedStyle(el);
|
|
31
|
+
if (computed.backgroundImage && computed.backgroundImage !== "none") {
|
|
32
|
+
bgImageOriginals.set(el, el.style.backgroundImage);
|
|
33
|
+
el.style.setProperty("background-image", "none", "important");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function restoreBackgroundImages() {
|
|
38
|
+
for (const [el, original] of bgImageOriginals) {
|
|
39
|
+
try {
|
|
40
|
+
el.style.backgroundImage = original;
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
bgImageOriginals.clear();
|
|
45
|
+
}
|
|
46
|
+
function setupMutationObserver() {
|
|
47
|
+
if (mutationObserver) return;
|
|
48
|
+
mutationObserver = new MutationObserver((mutations) => {
|
|
49
|
+
if (!enabled) return;
|
|
50
|
+
for (const mutation of mutations) {
|
|
51
|
+
for (const node of mutation.addedNodes) {
|
|
52
|
+
if (!(node instanceof HTMLElement)) continue;
|
|
53
|
+
if (node.closest("#accessify-root")) continue;
|
|
54
|
+
const computed = getComputedStyle(node);
|
|
55
|
+
if (computed.backgroundImage && computed.backgroundImage !== "none") {
|
|
56
|
+
bgImageOriginals.set(node, node.style.backgroundImage);
|
|
57
|
+
node.style.setProperty("background-image", "none", "important");
|
|
58
|
+
}
|
|
59
|
+
node.querySelectorAll("*").forEach((child) => {
|
|
60
|
+
if (child.closest("#accessify-root")) return;
|
|
61
|
+
const cs = getComputedStyle(child);
|
|
62
|
+
if (cs.backgroundImage && cs.backgroundImage !== "none") {
|
|
63
|
+
bgImageOriginals.set(child, child.style.backgroundImage);
|
|
64
|
+
child.style.setProperty("background-image", "none", "important");
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
mutationObserver.observe(document.body, { childList: true, subtree: true });
|
|
71
|
+
}
|
|
72
|
+
function activate() {
|
|
73
|
+
enabled = true;
|
|
74
|
+
let styleEl = document.getElementById(STYLE_ID);
|
|
75
|
+
if (!styleEl) {
|
|
76
|
+
styleEl = document.createElement("style");
|
|
77
|
+
styleEl.id = STYLE_ID;
|
|
78
|
+
document.head.appendChild(styleEl);
|
|
79
|
+
}
|
|
80
|
+
styleEl.textContent = CSS;
|
|
81
|
+
hideBackgroundImages();
|
|
82
|
+
setupMutationObserver();
|
|
83
|
+
}
|
|
84
|
+
function deactivate() {
|
|
85
|
+
enabled = false;
|
|
86
|
+
mutationObserver?.disconnect();
|
|
87
|
+
mutationObserver = null;
|
|
88
|
+
restoreBackgroundImages();
|
|
89
|
+
document.getElementById(STYLE_ID)?.remove();
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
id: "hide-images",
|
|
93
|
+
name: () => "Hide Images",
|
|
94
|
+
description: "Remove images for distraction-free reading",
|
|
95
|
+
icon: "hide-images",
|
|
96
|
+
category: "visual",
|
|
97
|
+
activate,
|
|
98
|
+
deactivate,
|
|
99
|
+
getState: () => ({ id: "hide-images", enabled })
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
createHideImagesModule as default
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=hide-images-B_LeCBcd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hide-images-B_LeCBcd.js","sources":["../src/features/hide-images.ts"],"sourcesContent":["import type { FeatureModule, FeatureState } from '../types';\n\nexport default function createHideImagesModule(): FeatureModule {\n let enabled = false;\n const STYLE_ID = 'accessify-hide-images';\n let bgImageOriginals = new Map<HTMLElement, string>();\n let mutationObserver: MutationObserver | null = null;\n\n const CSS = `\n /* Standard image elements */\n img, picture, svg:not([aria-hidden=\"true\"]), video, canvas,\n [role=\"img\"], figure {\n opacity: 0 !important;\n pointer-events: none !important;\n }\n\n /* CSS background-images (inline styles) */\n [style*=\"background-image\"] {\n background-image: none !important;\n }\n\n /* Lazy-load images that haven't loaded yet */\n img[data-src], img[data-lazy-src], img[data-original],\n img[loading=\"lazy\"] {\n opacity: 0 !important;\n pointer-events: none !important;\n }\n `;\n\n function hideBackgroundImages() {\n // Find elements with computed background-image (covers CSS classes, not just inline)\n const all = document.querySelectorAll<HTMLElement>('*');\n for (const el of all) {\n if (el.closest('#accessify-root')) continue;\n const computed = getComputedStyle(el);\n if (computed.backgroundImage && computed.backgroundImage !== 'none') {\n bgImageOriginals.set(el, el.style.backgroundImage);\n el.style.setProperty('background-image', 'none', 'important');\n }\n }\n }\n\n function restoreBackgroundImages() {\n for (const [el, original] of bgImageOriginals) {\n try {\n el.style.backgroundImage = original;\n } catch { /* element may be gone */ }\n }\n bgImageOriginals.clear();\n }\n\n function setupMutationObserver() {\n if (mutationObserver) return;\n mutationObserver = new MutationObserver((mutations) => {\n if (!enabled) return;\n for (const mutation of mutations) {\n for (const node of mutation.addedNodes) {\n if (!(node instanceof HTMLElement)) continue;\n if (node.closest('#accessify-root')) continue;\n // Hide background images on newly added elements\n const computed = getComputedStyle(node);\n if (computed.backgroundImage && computed.backgroundImage !== 'none') {\n bgImageOriginals.set(node, node.style.backgroundImage);\n node.style.setProperty('background-image', 'none', 'important');\n }\n // Also check children\n node.querySelectorAll<HTMLElement>('*').forEach((child) => {\n if (child.closest('#accessify-root')) return;\n const cs = getComputedStyle(child);\n if (cs.backgroundImage && cs.backgroundImage !== 'none') {\n bgImageOriginals.set(child, child.style.backgroundImage);\n child.style.setProperty('background-image', 'none', 'important');\n }\n });\n }\n }\n });\n mutationObserver.observe(document.body, { childList: true, subtree: true });\n }\n\n function activate() {\n enabled = true;\n let styleEl = document.getElementById(STYLE_ID);\n if (!styleEl) {\n styleEl = document.createElement('style');\n styleEl.id = STYLE_ID;\n document.head.appendChild(styleEl);\n }\n styleEl.textContent = CSS;\n hideBackgroundImages();\n setupMutationObserver();\n }\n\n function deactivate() {\n enabled = false;\n mutationObserver?.disconnect();\n mutationObserver = null;\n restoreBackgroundImages();\n document.getElementById(STYLE_ID)?.remove();\n }\n\n return {\n id: 'hide-images',\n name: () => 'Hide Images',\n description: 'Remove images for distraction-free reading',\n icon: 'hide-images',\n category: 'visual',\n activate,\n deactivate,\n getState: (): FeatureState => ({ id: 'hide-images', enabled }),\n };\n}\n"],"names":[],"mappings":"AAEA,SAAwB,yBAAwC;AAC9D,MAAI,UAAU;AACd,QAAM,WAAW;AACjB,MAAI,uCAAuB,IAAA;AAC3B,MAAI,mBAA4C;AAEhD,QAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBZ,WAAS,uBAAuB;AAE9B,UAAM,MAAM,SAAS,iBAA8B,GAAG;AACtD,eAAW,MAAM,KAAK;AACpB,UAAI,GAAG,QAAQ,iBAAiB,EAAG;AACnC,YAAM,WAAW,iBAAiB,EAAE;AACpC,UAAI,SAAS,mBAAmB,SAAS,oBAAoB,QAAQ;AACnE,yBAAiB,IAAI,IAAI,GAAG,MAAM,eAAe;AACjD,WAAG,MAAM,YAAY,oBAAoB,QAAQ,WAAW;AAAA,MAC9D;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Ac;AACtB,yBAAA;AACA,0BAAA;AAAA,EACF;AAEA,WAAS,aAAa;AACpB,cAAU;AACV,sBAAkB,WAAA;AAClB,uBAAmB;AACnB,4BAAA;AACA,aAAS,eAAe,QAAQ,GAAG,OAAA;AAAA,EACrC;AAEA,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,MAAM,MAAM;AAAA,IACZ,aAAa;AAAA,IACb,MAAM;AAAA,IACN,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA,UAAU,OAAqB,EAAE,IAAI,eAAe,QAAA;AAAA,EAAQ;AAEhE;"}
|
|
@@ -6310,16 +6310,16 @@ function FeatureGrid($$anchor, $$props) {
|
|
|
6310
6310
|
const FEATURE_LOADERS = {
|
|
6311
6311
|
contrast: () => import("./contrast-CqsICAkU.js"),
|
|
6312
6312
|
"text-size": () => import("./text-size-C6OFhCGi.js"),
|
|
6313
|
-
"keyboard-nav": () => import("./keyboard-nav-
|
|
6313
|
+
"keyboard-nav": () => import("./keyboard-nav-CAWn30Tw.js"),
|
|
6314
6314
|
"link-highlight": () => import("./link-highlight-DBGm067Y.js"),
|
|
6315
6315
|
"reading-guide": () => import("./reading-guide-VT8NciIL.js"),
|
|
6316
6316
|
"reading-mask": () => import("./reading-mask-BABChuCz.js"),
|
|
6317
|
-
"animation-stop": () => import("./animation-stop-
|
|
6318
|
-
"hide-images": () => import("./hide-images-
|
|
6317
|
+
"animation-stop": () => import("./animation-stop-C6ToNlBr.js"),
|
|
6318
|
+
"hide-images": () => import("./hide-images-B_LeCBcd.js"),
|
|
6319
6319
|
"big-cursor": () => import("./big-cursor-B2UKu9dQ.js"),
|
|
6320
|
-
"page-structure": () => import("./page-structure-
|
|
6320
|
+
"page-structure": () => import("./page-structure-DDjJeVCc.js"),
|
|
6321
6321
|
tts: () => import("./tts-CjszLRnb.js"),
|
|
6322
|
-
"text-simplify": () => import("./text-simplify-
|
|
6322
|
+
"text-simplify": () => import("./text-simplify-B1v6Muvn.js"),
|
|
6323
6323
|
"alt-text": () => Promise.resolve().then(() => altText)
|
|
6324
6324
|
};
|
|
6325
6325
|
let contrastMode = /* @__PURE__ */ state(proxy(readStoredContrastMode()));
|
|
@@ -7567,7 +7567,8 @@ async function fetchServerAltTexts(siteKey, proxyUrl, lang) {
|
|
|
7567
7567
|
const base = proxyUrl || DEFAULT_API_BASE;
|
|
7568
7568
|
const pageUrl = window.location.origin + window.location.pathname;
|
|
7569
7569
|
const res = await fetch(`${base}/v1/manifest?siteKey=${encodeURIComponent(siteKey)}&url=${encodeURIComponent(pageUrl)}&feature=alt_text&variant=${encodeURIComponent(lang)}`, {
|
|
7570
|
-
headers: { "Accept": "application/json" }
|
|
7570
|
+
headers: { "Accept": "application/json" },
|
|
7571
|
+
cache: "no-cache"
|
|
7571
7572
|
});
|
|
7572
7573
|
if (!res.ok) return map;
|
|
7573
7574
|
const data = await res.json();
|
|
@@ -7647,6 +7648,7 @@ async function autoApplyCachedAltTexts(widgetConfig) {
|
|
|
7647
7648
|
if (cached) {
|
|
7648
7649
|
img.setAttribute("alt", cached);
|
|
7649
7650
|
img.setAttribute("title", cached);
|
|
7651
|
+
img.setAttribute("data-accessify-alt", "auto");
|
|
7650
7652
|
applied++;
|
|
7651
7653
|
}
|
|
7652
7654
|
});
|
|
@@ -7662,6 +7664,7 @@ async function autoApplyCachedAltTexts(widgetConfig) {
|
|
|
7662
7664
|
if (c) {
|
|
7663
7665
|
img.setAttribute("alt", c);
|
|
7664
7666
|
img.setAttribute("title", c);
|
|
7667
|
+
img.setAttribute("data-accessify-alt", "auto");
|
|
7665
7668
|
}
|
|
7666
7669
|
}
|
|
7667
7670
|
}
|
|
@@ -7960,6 +7963,15 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
|
|
|
7960
7963
|
});
|
|
7961
7964
|
return missing;
|
|
7962
7965
|
}
|
|
7966
|
+
function scanAutoApplied() {
|
|
7967
|
+
const images = document.querySelectorAll('img[data-accessify-alt="auto"]');
|
|
7968
|
+
const applied = [];
|
|
7969
|
+
images.forEach((img) => {
|
|
7970
|
+
if (img.closest("#accessify-root")) return;
|
|
7971
|
+
if (!processedImages.has(img)) applied.push(img);
|
|
7972
|
+
});
|
|
7973
|
+
return applied;
|
|
7974
|
+
}
|
|
7963
7975
|
function applyAltText(img, altText2) {
|
|
7964
7976
|
img.setAttribute("alt", altText2);
|
|
7965
7977
|
img.setAttribute("title", altText2);
|
|
@@ -8127,8 +8139,23 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
|
|
|
8127
8139
|
if (enabled) return;
|
|
8128
8140
|
enabled = true;
|
|
8129
8141
|
injectStyles();
|
|
8130
|
-
|
|
8131
|
-
|
|
8142
|
+
const alreadyApplied = scanAutoApplied();
|
|
8143
|
+
for (const img of alreadyApplied) {
|
|
8144
|
+
const alt = img.getAttribute("alt");
|
|
8145
|
+
processedImages.set(img, { generatedAlt: alt });
|
|
8146
|
+
missingAltImages.push(img);
|
|
8147
|
+
img.classList.add(HIGHLIGHT_CLASS, "accessify-alt-done");
|
|
8148
|
+
addInfoButton(img);
|
|
8149
|
+
img.removeEventListener("mouseenter", onMouseEnter);
|
|
8150
|
+
img.removeEventListener("mouseleave", onMouseLeave);
|
|
8151
|
+
img.addEventListener("mouseenter", onMouseEnter);
|
|
8152
|
+
img.addEventListener("mouseleave", onMouseLeave);
|
|
8153
|
+
}
|
|
8154
|
+
const missing = scanForMissingAlt();
|
|
8155
|
+
for (const img of missing) {
|
|
8156
|
+
missingAltImages.push(img);
|
|
8157
|
+
img.classList.add(HIGHLIGHT_CLASS);
|
|
8158
|
+
}
|
|
8132
8159
|
updateBadge();
|
|
8133
8160
|
generateAll();
|
|
8134
8161
|
document.querySelectorAll("img").forEach((img) => {
|
|
@@ -8162,7 +8189,7 @@ function createAltTextModule(aiService, initialLang = "de", serverConfig) {
|
|
|
8162
8189
|
missingAltImages = [];
|
|
8163
8190
|
removeStyles();
|
|
8164
8191
|
}
|
|
8165
|
-
autoApplyCachedAltTexts().catch(() => {
|
|
8192
|
+
autoApplyCachedAltTexts({ siteKey, proxyUrl, lang: initialLang }).catch(() => {
|
|
8166
8193
|
});
|
|
8167
8194
|
return {
|
|
8168
8195
|
id: "alt-text",
|
|
@@ -8373,4 +8400,4 @@ export {
|
|
|
8373
8400
|
init as i,
|
|
8374
8401
|
t
|
|
8375
8402
|
};
|
|
8376
|
-
//# sourceMappingURL=index-
|
|
8403
|
+
//# sourceMappingURL=index-eprjFXa3.js.map
|