Skip to content

Instantly share code, notes, and snippets.

@easrng
Created May 19, 2022 23:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save easrng/7cf9d5914e0ccee9d0f3a7e3e75ac3f8 to your computer and use it in GitHub Desktop.
Save easrng/7cf9d5914e0ccee9d0f3a7e3e75ac3f8 to your computer and use it in GitHub Desktop.

A small notepad

Copy this link to the address bar:

data:text/html;charset=utf8,<style>body{max-width:70ch;margin:1rem auto;font-family:sans-serif;line-height:1.5rem}img{max-width:100%}</style><a id=l></a><br><button onclick="document.execCommand('bold')"><b>b</b></button><button onclick="document.execCommand('italic')"><i>i</i></button><button onclick="document.execCommand('underline')"><u>u</u></button><button onclick="document.execCommand('createLink',false,prompt('Link URL'))"><a href="javascript:;">l</a></button><div contenteditable id=b>%3Cdiv%3EA%20little%20notepad.%20Drag%20the%20link%20above%20to%20your%20bookmarks%20bar%20to%20save.%3C%2Fdiv%3E%3Cdiv%3EThere%20are%20%3Cb%3Esome%20%3C%2Fb%3E%3Ci%3Eformatting%20%3C%2Fi%3E%3Cu%3Eoptions%3C%2Fu%3E.%20When%20you%20make%20a%20%3Ca%20href%3D%22https%3A%2F%2Fexample.com%22%3Elink%3C%2Fa%3E%20you%20will%20need%20to%20right%20click%20to%20open%20it%20since%20clicking%20it%20just%20moves%20the%20cursor.%3Cbr%3E%3C%2Fdiv%3E</div><script id=s>const r=()=>{l.text='Note at '+new Date().toLocaleString();l.href='data:text/html;charset=utf8,<style>body{max-width:70ch;margin:1rem auto;font-family:sans-serif;line-height:1.5rem}img{max-width:100%}</style><a id=l></a><br><button onclick="document.execCommand(\'bold\')"><b>b</b></button><button onclick="document.execCommand(\'italic\')"><i>i</i></button><button onclick="document.execCommand(\'underline\')"><u>u</u></button><button onclick="document.execCommand(\'createLink\',false,prompt(\'Link URL\'))"><a href="javascript:;">l</a></button><div contenteditable id=b>'+encodeURIComponent(b.innerHTML)+'</div><script id=s>'+s.innerHTML+'</'+'script>'};new MutationObserver(r).observe(b,{characterData:!0,attributes:!0,childList:!0,subtree:!0});r();</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment