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

Function styleButton

chatgpt-code-tools/chatgpt-code-tools.user.js:541–568  ·  view source on GitHub ↗
(button)

Source from the content-addressed store, hash-verified

539
540 // Function to style the buttons
541 const styleButton = (button) => {
542 Object.assign(button.style, {
543 display: 'inline-block',
544 padding: '8px',
545 background: '#007bff', // Default standby color
546 color: 'white',
547 border: 'none',
548 borderRadius: '4px',
549 cursor: 'pointer',
550 transition: 'background-color 0.3s ease'
551 })
552
553 button.addEventListener('mouseover', () => {
554 if (button.textContent === 'Saving...' || button.textContent === 'Copied!' || button.textContent === 'Could not download' || button.textContent === 'Could not copy') {
555 button.style.backgroundColor = button.textContent.includes('Could not') ? 'darkred' : 'darkgreen'
556 } else {
557 button.style.backgroundColor = '#0056b3' // Darker blue for standby
558 }
559 })
560
561 button.addEventListener('mouseout', () => {
562 if (button.textContent === 'Saving...' || button.textContent === 'Copied!' || button.textContent === 'Could not download' || button.textContent === 'Could not copy') {
563 button.style.backgroundColor = button.textContent.includes('Could not') ? 'red' : 'green'
564 } else {
565 button.style.backgroundColor = '#007bff' // Default blue for standby
566 }
567 })
568 }
569
570 // Function to observe code blocks and add buttons
571 const observeCodeBlocks = () => {

Callers 1

addButtonsToCodeBlockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected