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

Function copyToClipboard

chatgpt-code-tools/chatgpt-code-tools.user.js:454–461  ·  view source on GitHub ↗
(text, button)

Source from the content-addressed store, hash-verified

452
453 // Function to copy text to the clipboard
454 const copyToClipboard = (text, button) => {
455 navigator.clipboard.writeText(text).then(() => {
456 setButtonState(button, 'working', 'copy')
457 }).catch((err) => {
458 console.error('Failed to copy code: ', err)
459 setButtonState(button, 'error', 'copy')
460 })
461 }
462
463 // Function to set the button state and color
464 const setButtonState = (button, state, type) => {

Callers 1

addButtonsToCodeBlockFunction · 0.70

Calls 1

setButtonStateFunction · 0.85

Tested by

no test coverage detected