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

Function insertBackticks

chatgpt-insert-text/chatgpt-insert-text.user.js:462–472  ·  view source on GitHub ↗
(text)

Source from the content-addressed store, hash-verified

460
461 //Separate function for the backticks. Change the key to what works on your keyboard
462 function insertBackticks(text) {
463 let activeElement = document.activeElement
464 if (activeElement.tagName === 'INPUT' || activeElement.tagName === 'TEXTAREA') {
465 let start = activeElement.selectionStart
466 let end = activeElement.selectionEnd
467 activeElement.value = activeElement.value.slice(0, start) + text + activeElement.value.slice(end)
468 activeElement.selectionStart = activeElement.selectionEnd = start + text.length
469 } else if (activeElement.isContentEditable) {
470 document.execCommand('insertText', false, text)
471 }
472 }
473})()

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected