MCPcopy
hub / github.com/mailvelope/mailvelope / setRecipients

Method setRecipients

src/content-scripts/providerSpecific.js:154–177  ·  view source on GitHub ↗

* Set the recipients in the Yahoo Webmail editor.

({recipients = []})

Source from the content-addressed store, hash-verified

152 * Set the recipients in the Yahoo Webmail editor.
153 */
154 setRecipients({recipients = []}) {
155 const input = document.querySelector('.compose-header [data-test-id="container-to"] ul.pill-list > li.pill-container input.input-to');
156 const inputValue = joinEmail(recipients);
157 setReactValue(input, inputValue);
158 // trigger change event by switching focus
159 setFocus(input)
160 .then(() => {
161 const subject = document.querySelector('[data-test-id="compose-subject"]');
162 // set focus to subject field, or to compose area in the reply case
163 setFocus(isVisible(subject) ? subject : document.querySelector('[id="editor-container"] > [data-test-id="rte"]'));
164 });
165
166 // remove existing recipients afterwards
167 setTimeout(() => {
168 document.querySelectorAll('.compose-header [data-test-id="container-to"] ul.pill-list > li:not(.pill-container)').forEach(element => {
169 const dataElement = element.querySelector('[data-test-id="pill"]');
170 const parsed = parseAddressSafe(dataElement.getAttribute('title'));
171 if (parsed && !recipients.find(({email}) => email === parsed.email)) {
172 element.click();
173 element.querySelector('.pill-close button').click();
174 }
175 });
176 }, 250);
177 }
178
179 /**
180 * Extract sender

Callers

nothing calls this directly

Calls 5

isVisibleFunction · 0.90
parseAddressSafeFunction · 0.90
joinEmailFunction · 0.85
setFocusFunction · 0.85
setReactValueFunction · 0.70

Tested by

no test coverage detected