Skip to content

Instantly share code, notes, and snippets.

@lucahammer
Last active April 3, 2018 08:08
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 lucahammer/c2b23ced71198c9b292327efa6ea05bf to your computer and use it in GitHub Desktop.
Save lucahammer/c2b23ced71198c9b292327efa6ea05bf to your computer and use it in GitHub Desktop.
Typo Bookmarklets
// Copy a zero width whitespace to the clipboard
// Adds a element to the document, selects it, adds it to the clipboard and removes it
// Source: https://stackoverflow.com/questions/5046972/copy-text-to-clipboard-from-bookmarklet
javascript:!function(a){var b=document.createElement("textarea"),c=document.getSelection();b.textContent=a,document.body.appendChild(b),c.removeAllRanges(),b.select(),document.execCommand("copy"),c.removeAllRanges(),document.body.removeChild(b)}("​");
// Add Proper Quotation Marks
// Adds quotations marks around selected text
// Source https://stackoverflow.com/questions/40584878/how-to-create-a-js-bookmarklet-to-insert-fixed-text-at-cursor-position
javascript:(function(a){a.value=a.value.slice(0,a.selectionStart)+"„"+a.value.slice(a.selectionStart,a.selectionEnd)+"“"+a.value.slice(a.selectionEnd);})(document.activeElement);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment