Code that will take a filename and text data and have the user download it.
data:text/html,<input id="filenameInput" value="file-to-save.txt"/><button onclick="downloadToFile(filenameInput.value, contentInput.value)">Download File</button><textarea id="contentInput" style="width:100%" rows="10">Content</textarea><script>const downloadToFile=(filename,content)=>{if(!content){alert("No content to save!");return;}
const a=document.createElement("a");const file=new Blob([content],{type:"text/plain"});a.href=URL.createObjectURL(file);a.download=filename;a.click();URL.revokeObjectURL(a.href);};</script>