MCPcopy Create free account
hub / github.com/Surfer-Org/Protocol / waitForContentToStabilize

Function waitForContentToStabilize

desktop/src/main/preloadFunctions.js:53–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

51}
52
53async function waitForContentToStabilize() {
54 return new Promise((resolve) => {
55 let timeout;
56 const observer = new MutationObserver(() => {
57 clearTimeout(timeout);
58 timeout = setTimeout(() => {
59 observer.disconnect();
60 console.log('Content has stabilized');
61 resolve();
62 }, 100); // Adjust this delay as needed
63 });
64
65 observer.observe(document.body, {
66 childList: true,
67 subtree: true,
68 attributes: true,
69 });
70
71 // Fallback in case the page never stabilizes
72 setTimeout(() => {
73 observer.disconnect();
74 console.log('Timed out waiting for content to stabilize');
75 resolve();
76 }, 5000); // Adjust this timeout as needed
77 });
78}
79
80
81

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected