mirror of
https://github.com/multipleof4/.sune.git
synced 2026-04-27 18:22:14 +00:00
1 line
6.6 KiB
Plaintext
1 line
6.6 KiB
Plaintext
[{"id":"1esgs6k","name":"1 Click Proton Email","pinned":false,"avatar":"","url":"gh://multipleof4/.sune/proton-send.sune","updatedAt":1775773276906,"settings":{"model":"","temperature":"","top_p":"","top_k":"","frequency_penalty":"","repetition_penalty":"","min_p":"","top_a":"","verbosity":"","reasoning_effort":"default","system_prompt":"","html":"<!--\nSune: 1-Click Proton Email Sender\nVersion: 1.0\nAuth: USER.customKey1 (set in Account Settings > API > Custom Key 1)\n-->\n<div id=\"sune_email_sender\" x-data=\"{v:'1.0'}\" class=\"hidden\"></div>\n<script>\n(()=>{\n const suneEl=document.getElementById('sune_email_sender');\n if(!suneEl){console.error(\"Sune email container not found.\");return}\n const SUNE_NAME='[Sune: Email Sender]',\n SUNE_V=suneEl.getAttribute('x-data').match(/v:'(.*?)'/)[1],\n ENDPOINT='https://proton.planetrenox.com/send';\n console.log(`${SUNE_NAME} Initializing v${SUNE_V}`);\n\n const defaultClasses=['bg-slate-100','text-slate-700','hover:bg-slate-200'],\n successClasses=['bg-green-100','text-green-800'],\n errorClasses=['bg-red-100','text-red-800'];\n\n const KNOWN_KEYS=/^(DISPLAY_NAME|TO|SUBJECT|BODY|IN_REPLY_TO|REFERENCES)\\s*:\\s*(.*)/i;\n\n const parseEmailBlock=raw=>{\n const fields={},lines=raw.split('\\n');\n let curKey=null,curVal='';\n for(const line of lines){\n const m=line.match(KNOWN_KEYS);\n if(m){\n if(curKey)fields[curKey]=curVal;\n curKey=m[1].toUpperCase();\n curVal=m[2];\n }else if(curKey){\n curVal+='\\n'+line;\n }\n }\n if(curKey)fields[curKey]=curVal;\n for(const k in fields){\n let v=fields[k].trim();\n if(v.startsWith('\"')&&v.endsWith('\"'))v=v.slice(1,-1);\n fields[k]=v.replace(/\\\\n/g,'\\n');\n }\n return fields;\n };\n\n const sendEmail=async(btn,fields)=>{\n const auth=window.USER?.customKey1;\n if(!auth){alert('Email auth password not set.\\nAccount Settings → API → Custom Key 1');return}\n\n btn.disabled=true;\n btn.innerHTML='<span class=\"relative flex h-3 w-3\"><span class=\"animate-ping absolute inline-flex h-full w-full rounded-full bg-sky-400 opacity-75\"></span><span class=\"relative inline-flex rounded-full h-3 w-3 bg-sky-500\"></span></span> Sending...';\n\n try{\n const body={auth,to:fields.TO,subject:fields.SUBJECT||'(no subject)',text:fields.BODY||''};\n if(fields.DISPLAY_NAME)body.display_name=fields.DISPLAY_NAME;\n if(fields.IN_REPLY_TO)body.in_reply_to=fields.IN_REPLY_TO;\n if(fields.REFERENCES)body.references=fields.REFERENCES;\n\n const res=await fetch(ENDPOINT,{\n method:'POST',\n headers:{'Content-Type':'application/json'},\n body:JSON.stringify(body)\n });\n const data=await res.json();\n if(!res.ok)throw new Error(data.error||`HTTP ${res.status}`);\n\n btn.classList.remove(...defaultClasses);btn.classList.add(...successClasses);\n btn.innerHTML='<i data-lucide=\"check\" class=\"h-3.5 w-3.5\"></i> Sent';\n }catch(err){\n alert(`${SUNE_NAME} Send Failed:\\n\\n${err.message}`);\n btn.classList.remove(...defaultClasses);btn.classList.add(...errorClasses);\n btn.innerHTML='<i data-lucide=\"x\" class=\"h-3.5 w-3.5\"></i> Failed';\n setTimeout(()=>{\n btn.disabled=false;\n btn.classList.remove(...errorClasses);btn.classList.add(...defaultClasses);\n btn.innerHTML='<i data-lucide=\"send\" class=\"h-3.5 w-3.5\"></i> Send Email';\n window.lucide?.createIcons();\n },4e3);\n }finally{window.lucide?.createIcons()}\n };\n\n const processBubble=bubble=>{\n if(!bubble||bubble.dataset.suneEmlProcessed)return;\n let added=false;\n\n bubble.querySelectorAll('code[class*=\"language-email\"]').forEach(code=>{\n const pre=code.closest('pre');\n if(!pre||pre.dataset.emlBtn)return;\n\n const fields=parseEmailBlock(code.textContent);\n if(!fields.TO||!fields.BODY)return;\n\n const to=fields.TO,subj=fields.SUBJECT||'(no subject)';\n const isReply=!!fields.IN_REPLY_TO;\n const label=isReply?'Reply':'Send Email';\n const icon=isReply?'reply':'send';\n\n const wrapper=document.createElement('div');\n wrapper.className='flex items-center gap-2 mt-2 flex-wrap';\n\n const preview=document.createElement('span');\n preview.className='text-[11px] text-gray-400 truncate max-w-[260px]';\n preview.textContent=`→ ${to} · ${subj}`;\n\n const btn=document.createElement('button');\n btn.className='email-send-btn inline-flex items-center gap-1.5 rounded-md bg-slate-100 px-2.5 py-1.5 text-xs font-medium text-slate-700 hover:bg-slate-200 transition-colors';\n btn.innerHTML=`<i data-lucide=\"${icon}\" class=\"h-3.5 w-3.5\"></i> ${label}`;\n btn.onclick=()=>sendEmail(btn,fields);\n\n wrapper.append(btn,preview);\n pre.dataset.emlBtn='true';\n pre.insertAdjacentElement('afterend',wrapper);\n added=true;\n });\n\n if(added){\n bubble.dataset.suneEmlProcessed='true';\n window.lucide?.createIcons();\n }\n return added;\n };\n\n const scanExisting=()=>document.querySelectorAll('#messages .msg-bubble').forEach(processBubble);\n\n const observer=new MutationObserver(mutations=>{\n for(const m of mutations)\n for(const node of m.addedNodes)\n if(node.nodeType===1){\n const b=node.matches?.('.msg-bubble')?[node]:node.querySelectorAll?.('.msg-bubble');\n b?.forEach(processBubble);\n }\n });\n\n const newResponseListener=e=>{\n const id=e?.detail?.message?.id;if(!id)return;\n let attempts=0;\n const tryProcess=()=>{\n attempts++;\n const bubble=window.getBubbleById(id);\n if(bubble&&processBubble(bubble))return;\n if(attempts<8)setTimeout(tryProcess,300);\n };\n setTimeout(tryProcess,150);\n };\n\n const composerEl=window.el?.composer,chatContainer=window.el?.messages;\n if(chatContainer&&composerEl){\n observer.observe(chatContainer,{childList:true,subtree:true});\n composerEl.addEventListener('sune:newSuneResponse',newResponseListener);\n scanExisting();\n console.log(`${SUNE_NAME} Observer active. Initial scan complete.`);\n }\n\n suneEl.addEventListener('sune:unmount',()=>{\n observer.disconnect();\n if(composerEl)composerEl.removeEventListener('sune:newSuneResponse',newResponseListener);\n console.log(`${SUNE_NAME} Unmounted.`);\n });\n})();\n</script>\n","extension_html":"<sune src='https://raw.githubusercontent.com/sune-org/store/refs/heads/main/sync.sune' private></sune>","hide_composer":true,"include_thoughts":false,"img_output":false,"aspect_ratio":"1:1","image_size":"1K","ignore_master_prompt":false},"storage":{}}] |