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

Function downloadFile

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

Source from the content-addressed store, hash-verified

438
439 // Function to download the text as a file
440 const downloadFile = (text, filename, button) => {
441 const blob = new Blob([text], { type: getMimeType(filename) })
442 const url = URL.createObjectURL(blob)
443 const a = document.createElement('a')
444 a.href = url
445 a.download = filename
446 document.body.appendChild(a)
447 a.click()
448 document.body.removeChild(a)
449 URL.revokeObjectURL(url)
450 setButtonState(button, 'working', 'download')
451 }
452
453 // Function to copy text to the clipboard
454 const copyToClipboard = (text, button) => {

Callers 1

addButtonsToCodeBlockFunction · 0.70

Calls 2

getMimeTypeFunction · 0.85
setButtonStateFunction · 0.85

Tested by

no test coverage detected