Last active
March 22, 2024 23:09
-
-
Save pointofpresence/b97c2b0033da79775ff6a967f69ff814 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:void function(){function truncateString(e,t){return e.length>t?e.slice(0,t):e}const title=document.title,href=location.href,host=new URL(href).host,cleanHost=host.replace(/[^a-zA-Z0-9]/g,"-");let finalHost=cleanHost.replace(/--/g,"-");finalHost.length||(finalHost="local");let sel=window.getSelection().toString();0===sel.length&&(sel=prompt("Description"));let text=`## ${title}\n\n${href}${sel&&sel.length>0?`\n\n${sel}`:""}`;const textarea=document.createElement("textarea");textarea.value=text,document.body.appendChild(textarea),textarea.select(),document.execCommand("copy");let command=`obsidian://advanced-uri?filepath=__INBOX/${finalHost}&mode=new`;if(document.queryCommandSupported("copy")){const e=document.execCommand("copy");document.body.removeChild(textarea),e?(console.log("Текст успешно скопирован в буфер обмена"),command=`obsidian://advanced-uri?filepath=__INBOX/${finalHost}&clipboard=true&mode=new`):(console.error("Перенос через URL"),command=truncateString(`${command}&data=${text=encodeURIComponent(text)}`,2046))}window.location.href=command;}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment