MCPcopy Create free account
hub / github.com/UNLINEARITY/Obsidian-CodeSpace / scanPopup

Function scanPopup

src/native_pdf_export_patch.ts:194–229  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

192 };
193
194 const scanPopup = () => {
195 if (popupWindow.closed) {
196 debugNativePdf(session, "popup window closed");
197 cleanup();
198 return;
199 }
200
201 const popupDoc = popupWindow.document;
202 const popupBody = popupDoc.body;
203 if (!popupBody) {
204 return;
205 }
206
207 const printRoots = Array.from(popupDoc.querySelectorAll<HTMLElement>(".print"));
208 const fileEmbedCount = popupDoc.querySelectorAll(".file-embed").length;
209 const signature = `print:${printRoots.length}|embed:${fileEmbedCount}`;
210 if (session.lastPopupScanSignature !== signature) {
211 session.lastPopupScanSignature = signature;
212 debugNativePdf(session, "popup scan state changed", {
213 printRoots: printRoots.length,
214 fileEmbeds: fileEmbedCount,
215 url: popupWindow.location.href,
216 });
217 }
218
219 if (printRoots.length > 0) {
220 for (const root of printRoots) {
221 void replacePopupCodeEmbeds(root, plugin, session.sourceFile.path);
222 }
223 return;
224 }
225
226 if (popupBody.querySelector(".file-embed")) {
227 void replacePopupCodeEmbeds(popupBody, plugin, session.sourceFile.path);
228 }
229 };
230
231 try {
232 debugNativePdf(session, "attached popup observer");

Callers 1

Calls 3

debugNativePdfFunction · 0.85
cleanupFunction · 0.85
replacePopupCodeEmbedsFunction · 0.85

Tested by

no test coverage detected