MCPcopy
hub / github.com/mailvelope/mailvelope / waitForPersonaCard

Method waitForPersonaCard

src/content-scripts/providerSpecific.js:211–237  ·  view source on GitHub ↗
(action)

Source from the content-addressed store, hash-verified

209 }
210
211 waitForPersonaCard(action) {
212 return new Promise((resolve, reject) => {
213 // create observer to wait for persona popup
214 const observer = new MutationObserver(mutations => {
215 mutations.forEach(mutation => {
216 if (!mutation.addedNodes.length) {
217 return;
218 }
219 const addedNode = mutation.addedNodes.item(0);
220 observer.disconnect();
221 // wait in interval for popup content to render
222 const searchInterval = setInterval(() => {
223 const personaCard = addedNode.querySelector('[data-log-name="Email"] button');
224 if (personaCard && extractAddressFromText(personaCard.textContent)) {
225 clearInterval(searchInterval);
226 // still more time required to complete render
227 setTimeout(() => resolve({personaCard, addedNode}), 200);
228 }
229 }, 100);
230 setTimeout(() => clearInterval(searchInterval), 1500);
231 });
232 });
233 observer.observe(document.body, {childList: true});
234 setTimeout(() => reject(observer.disconnect()), 1000);
235 action && action();
236 });
237 }
238
239 extractPersona(pane) {
240 if (!pane) {

Callers 1

extractPersonaMethod · 0.95

Calls 4

extractAddressFromTextFunction · 0.90
resolveFunction · 0.85
observeMethod · 0.80
disconnectMethod · 0.45

Tested by

no test coverage detected