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

Function setButtonState

chatgpt-code-tools/chatgpt-code-tools.user.js:464–488  ·  view source on GitHub ↗
(button, state, type)

Source from the content-addressed store, hash-verified

462
463 // Function to set the button state and color
464 const setButtonState = (button, state, type) => {
465 switch (state) {
466 case 'working':
467 button.textContent = type === 'download' ? 'Saving...' : 'Copied!'
468 button.style.backgroundColor = 'green'
469 break
470 case 'error':
471 button.textContent = type === 'download' ? 'Could not download' : 'Could not copy'
472 button.style.backgroundColor = 'red'
473 break
474 case 'standby':
475 default:
476 button.textContent = button.dataset.defaultText || 'Unknown'
477 button.style.backgroundColor = '#007bff' // Blue
478 break
479 }
480 button.style.color = 'white'
481
482 // Revert the button to standby after 5 seconds
483 if (state === 'working' || state === 'error') {
484 setTimeout(() => {
485 setButtonState(button, 'standby', type)
486 }, 5000) // 5 seconds
487 }
488 }
489
490 // Function to add save and copy buttons to a code block
491 const addButtonsToCodeBlock = (codeBlock) => {

Callers 2

downloadFileFunction · 0.85
copyToClipboardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected