accessify-widget 0.3.93 → 0.3.94

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.
@@ -1,4 +1,4 @@
1
- import { d, i } from "./index-RLG-UjSk.js";
1
+ import { d, i } from "./index-DYkpRTjy.js";
2
2
  export {
3
3
  d as destroy,
4
4
  i as init
@@ -5,15 +5,16 @@ function createHideImagesModule() {
5
5
  let mutationObserver = null;
6
6
  const CSS = `
7
7
  /* Standard image elements */
8
- img, picture, svg:not([aria-hidden="true"]), video, canvas,
9
- [role="img"], figure {
8
+ img, picture, video, canvas,
9
+ [role="img"] {
10
10
  opacity: 0 !important;
11
11
  pointer-events: none !important;
12
12
  }
13
13
 
14
- /* CSS background-images (inline styles) */
15
- [style*="background-image"] {
16
- background-image: none !important;
14
+ /* SVGs that are decorative images (not icons or UI elements) */
15
+ svg:not([aria-hidden="true"]):not([width]):not([class*="icon"]) {
16
+ opacity: 0 !important;
17
+ pointer-events: none !important;
17
18
  }
18
19
 
19
20
  /* Lazy-load images that haven't loaded yet */
@@ -23,12 +24,17 @@ function createHideImagesModule() {
23
24
  pointer-events: none !important;
24
25
  }
25
26
  `;
27
+ function isImageUrl(bgValue) {
28
+ return /url\s*\(/.test(bgValue) && !/gradient\s*\(/.test(bgValue);
29
+ }
26
30
  function hideBackgroundImages() {
27
- const all = document.querySelectorAll("*");
28
- for (const el of all) {
31
+ const candidates = document.querySelectorAll(
32
+ '[style*="background-image"], [style*="background:"], figure, [class*="image"], [class*="photo"], [class*="hero"], [class*="banner"], [data-framer-background-image-wrapper]'
33
+ );
34
+ for (const el of candidates) {
29
35
  if (el.closest("#accessify-root")) continue;
30
36
  const computed = getComputedStyle(el);
31
- if (computed.backgroundImage && computed.backgroundImage !== "none") {
37
+ if (computed.backgroundImage && computed.backgroundImage !== "none" && isImageUrl(computed.backgroundImage)) {
32
38
  bgImageOriginals.set(el, el.style.backgroundImage);
33
39
  el.style.setProperty("background-image", "none", "important");
34
40
  }
@@ -52,14 +58,14 @@ function createHideImagesModule() {
52
58
  if (!(node instanceof HTMLElement)) continue;
53
59
  if (node.closest("#accessify-root")) continue;
54
60
  const computed = getComputedStyle(node);
55
- if (computed.backgroundImage && computed.backgroundImage !== "none") {
61
+ if (computed.backgroundImage && computed.backgroundImage !== "none" && isImageUrl(computed.backgroundImage)) {
56
62
  bgImageOriginals.set(node, node.style.backgroundImage);
57
63
  node.style.setProperty("background-image", "none", "important");
58
64
  }
59
- node.querySelectorAll("*").forEach((child) => {
65
+ node.querySelectorAll('img, picture, video, [role="img"], [style*="background-image"]').forEach((child) => {
60
66
  if (child.closest("#accessify-root")) return;
61
67
  const cs = getComputedStyle(child);
62
- if (cs.backgroundImage && cs.backgroundImage !== "none") {
68
+ if (cs.backgroundImage && cs.backgroundImage !== "none" && isImageUrl(cs.backgroundImage)) {
63
69
  bgImageOriginals.set(child, child.style.backgroundImage);
64
70
  child.style.setProperty("background-image", "none", "important");
65
71
  }
@@ -102,4 +108,4 @@ function createHideImagesModule() {
102
108
  export {
103
109
  createHideImagesModule as default
104
110
  };
105
- //# sourceMappingURL=hide-images-B_LeCBcd.js.map
111
+ //# sourceMappingURL=hide-images-DdZdru63.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hide-images-DdZdru63.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, video, canvas,\n [role=\"img\"] {\n opacity: 0 !important;\n pointer-events: none !important;\n }\n\n /* SVGs that are decorative images (not icons or UI elements) */\n svg:not([aria-hidden=\"true\"]):not([width]):not([class*=\"icon\"]) {\n opacity: 0 !important;\n pointer-events: 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 /** Only target actual image URLs, not CSS gradients or layout backgrounds */\n function isImageUrl(bgValue: string): boolean {\n return /url\\s*\\(/.test(bgValue) && !/gradient\\s*\\(/.test(bgValue);\n }\n\n function hideBackgroundImages() {\n // Target elements likely to be image containers — not every element on the page.\n // Scanning all (*) kills section backgrounds, gradients, and overlays on Framer sites.\n const candidates = document.querySelectorAll<HTMLElement>(\n '[style*=\"background-image\"], [style*=\"background:\"], figure, ' +\n '[class*=\"image\"], [class*=\"photo\"], [class*=\"hero\"], [class*=\"banner\"], ' +\n '[data-framer-background-image-wrapper]'\n );\n for (const el of candidates) {\n if (el.closest('#accessify-root')) continue;\n const computed = getComputedStyle(el);\n if (computed.backgroundImage && computed.backgroundImage !== 'none' && isImageUrl(computed.backgroundImage)) {\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 only on actual image URLs (not gradients)\n const computed = getComputedStyle(node);\n if (computed.backgroundImage && computed.backgroundImage !== 'none' && isImageUrl(computed.backgroundImage)) {\n bgImageOriginals.set(node, node.style.backgroundImage);\n node.style.setProperty('background-image', 'none', 'important');\n }\n // Check image-related children (not all *)\n node.querySelectorAll<HTMLElement>('img, picture, video, [role=\"img\"], [style*=\"background-image\"]').forEach((child) => {\n if (child.closest('#accessify-root')) return;\n const cs = getComputedStyle(child);\n if (cs.backgroundImage && cs.backgroundImage !== 'none' && isImageUrl(cs.backgroundImage)) {\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;AAAA;AAuBZ,WAAS,WAAW,SAA0B;AAC5C,WAAO,WAAW,KAAK,OAAO,KAAK,CAAC,gBAAgB,KAAK,OAAO;AAAA,EAClE;AAEA,WAAS,uBAAuB;AAG9B,UAAM,aAAa,SAAS;AAAA,MAC1B;AAAA,IAAA;AAIF,eAAW,MAAM,YAAY;AAC3B,UAAI,GAAG,QAAQ,iBAAiB,EAAG;AACnC,YAAM,WAAW,iBAAiB,EAAE;AACpC,UAAI,SAAS,mBAAmB,SAAS,oBAAoB,UAAU,WAAW,SAAS,eAAe,GAAG;AAC3G,yBAAiB,IAAI,IAAI,GAAG,MAAM,eAAe;AACjD,WAAG,MAAM,YAAY,oBAAoB,QAA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xC,cAAQ,KAAK;AACb,eAAS,KAAK,YAAY,OAAO;AAAA,IACnC;AACA,YAAQ,cAAc;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;"}
@@ -6642,14 +6642,14 @@ function FeatureGrid($$anchor, $$props) {
6642
6642
  const FEATURE_LOADERS = {
6643
6643
  contrast: () => import("./contrast-CqsOs6Uo.js"),
6644
6644
  "text-size": () => import("./text-size-m_mHNPWo.js"),
6645
- "keyboard-nav": () => import("./keyboard-nav-wu9L4ZxP.js"),
6645
+ "keyboard-nav": () => import("./keyboard-nav-C5z8cU6u.js"),
6646
6646
  "link-highlight": () => import("./link-highlight-DBGm067Y.js"),
6647
6647
  "reading-guide": () => import("./reading-guide-VT8NciIL.js"),
6648
6648
  "reading-mask": () => import("./reading-mask-BABChuCz.js"),
6649
6649
  "animation-stop": () => import("./animation-stop-C2Ced0LV.js"),
6650
- "hide-images": () => import("./hide-images-B_LeCBcd.js"),
6650
+ "hide-images": () => import("./hide-images-DdZdru63.js"),
6651
6651
  "big-cursor": () => import("./big-cursor-B2UKu9dQ.js"),
6652
- "page-structure": () => import("./page-structure-DLIXirOX.js"),
6652
+ "page-structure": () => import("./page-structure-CwiOhsWl.js"),
6653
6653
  tts: () => import("./tts-CjszLRnb.js"),
6654
6654
  "text-simplify": () => import("./text-simplify-BxIySphr.js"),
6655
6655
  "alt-text": () => Promise.resolve().then(() => altText)
@@ -9063,4 +9063,4 @@ export {
9063
9063
  init as i,
9064
9064
  t
9065
9065
  };
9066
- //# sourceMappingURL=index-RLG-UjSk.js.map
9066
+ //# sourceMappingURL=index-DYkpRTjy.js.map