MCPcopy Create free account
hub / github.com/PaperDebugger/paperdebugger / onElementAppeared

Function onElementAppeared

webapp/_webapp/src/libs/helpers.ts:4–22  ·  view source on GitHub ↗
(selector: string, callback: (element: Element) => void)

Source from the content-addressed store, hash-verified

2import { storage } from "./storage";
3
4export async function onElementAppeared(selector: string, callback: (element: Element) => void) {
5 const element = document.querySelector(selector);
6 if (element) {
7 return callback(element);
8 }
9
10 const observer = new MutationObserver(() => {
11 const element = document.querySelector(selector);
12 if (element) {
13 observer.disconnect();
14 callback(element);
15 }
16 });
17
18 observer.observe(document.body, {
19 childList: true,
20 subtree: true,
21 });
22}
23
24export function onElementAdded(selector: string, callback: (element: Element) => void) {
25 const observer = new MutationObserver((mutations) => {

Callers 2

main.tsxFile · 0.90
UISettingsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected