From 381d5c8048cc5dbb0feb0072110d6014ef1134de Mon Sep 17 00:00:00 2001 From: Hirosashii Date: Fri, 21 Nov 2025 01:21:57 -0500 Subject: [PATCH] Delete src/hooks/useExposeIframeText.ts --- src/hooks/useExposeIframeText.ts | 56 -------------------------------- 1 file changed, 56 deletions(-) delete mode 100644 src/hooks/useExposeIframeText.ts diff --git a/src/hooks/useExposeIframeText.ts b/src/hooks/useExposeIframeText.ts deleted file mode 100644 index cc8323e..0000000 --- a/src/hooks/useExposeIframeText.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { useEffect } from "react"; - -export function useExposeIframeText(iframeSelector = "iframe[id^='epubjs-view']") { - useEffect(() => { - const iframe = document.querySelector(iframeSelector); - if (!iframe) return; - - const mirrorId = "migaku-readable-layer"; - - // Create mirror layer if it doesn't exist - let mirror = document.getElementById(mirrorId); - if (!mirror) { - mirror = document.createElement("div"); - mirror.id = mirrorId; - - Object.assign(mirror.style, { - position: "absolute", - inset: "0", - padding: "50px", - pointerEvents: "none", // important – do NOT block viewer interactions - color: "transparent", - userSelect: "text", - whiteSpace: "pre-wrap", - zIndex: 1, // below UI overlays, above background - fontSize: "16px", - }); - - document.body.appendChild(mirror); - } - - function syncText() { - try { - const doc = iframe.contentDocument; - if (!doc) return; - - // Extract all text from inside the iframe body - let text = ""; - doc.querySelectorAll("p, h1, h2, h3, h4, span").forEach((el) => { - text += el.innerText + "\n"; - }); - - mirror!.textContent = text; - } catch (e) { - console.warn("Unable to access iframe text:", e); - } - } - - // Sync initially - syncText(); - - // Sync whenever iframe loads a new chapter - iframe.addEventListener("load", syncText); - - return () => iframe.removeEventListener("load", syncText); - }, [iframeSelector]); -}