MCPcopy Create free account
hub / github.com/ImGoodBai/MapGoGoGo / copyText

Function copyText

frontend/src/App.tsx:89–117  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

87}
88
89async function copyText(text: string) {
90 if (navigator.clipboard?.writeText && window.isSecureContext) {
91 try {
92 await navigator.clipboard.writeText(text);
93 return true;
94 } catch {
95 // Continue to the textarea fallback below.
96 }
97 }
98
99 const textarea = document.createElement("textarea");
100 textarea.value = text;
101 textarea.setAttribute("readonly", "");
102 textarea.style.left = "-9999px";
103 textarea.style.opacity = "0";
104 textarea.style.position = "fixed";
105 textarea.style.top = "0";
106 document.body.appendChild(textarea);
107 textarea.focus();
108 textarea.select();
109 textarea.setSelectionRange(0, text.length);
110 try {
111 return document.execCommand("copy");
112 } catch {
113 return false;
114 } finally {
115 document.body.removeChild(textarea);
116 }
117}
118
119function isWeChat() {
120 return /MicroMessenger/i.test(navigator.userAgent);

Callers 1

shareChallengeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected