MCPcopy Create free account
hub / github.com/ChinaGodMan/UserScripts / copyToClipboard

Function copyToClipboard

github-email-finder/github-email-finder.user.js:428–444  ·  view source on GitHub ↗
(_window, _document, _navigator)

Source from the content-addressed store, hash-verified

426</svg></div></div>`
427
428async function copyToClipboard(_window, _document, _navigator) {
429 const email = _document.querySelector(EMAIL_CLASS)
430 if (email) {
431 const selection = _window?.getSelection()?.selectAllChildren(email)
432
433 await _navigator.clipboard.writeText(email.textContent || '')
434 // Unselect text
435 _window.getSelection()?.removeAllRanges()
436
437 const divContainer = _document.querySelector(`#${CLIPBOARD_CONTAINER_DIV_ID}`)
438
439 if (divContainer) {
440 // Replace element with our other one
441 divContainer.outerHTML = copiedCheckMarkHTML
442 }
443 }
444}
445
446function registerCopyToClipboardEventListener(_window, _document, _navigator, divElement) {
447 divElement.addEventListener('click', () => {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected