Skip to content

Instantly share code, notes, and snippets.

@cdzombak
Last active September 26, 2019 16:32
Show Gist options
  • Select an option

  • Save cdzombak/ac36376c195006d886e76fdc2241c822 to your computer and use it in GitHub Desktop.

Select an option

Save cdzombak/ac36376c195006d886e76fdc2241c822 to your computer and use it in GitHub Desktop.
Bookmarklet which builds a Markdown link to the current page
javascript:!function(){var%20e=window.getSelection().toString(),t=document.title.replace(%22%20-%20Jira%22,%22%22),n=e%3Fe:t,o=%22[%22+n+%22](%22+location.href+%22)%22;(function(e){var%20t=document.createElement(%22textarea%22),n=document.getSelection();t.textContent=e,document.body.appendChild(t),n.removeAllRanges(),t.select(),document.execCommand(%22copy%22),n.removeAllRanges(),document.body.removeChild(t)})(o)}();
@cdzombak
Copy link
Copy Markdown
Author

cdzombak commented Jan 8, 2019

This bookmarklet builds a Markdown link to the current page, using the selected text (if any) or the page title as the link title.

Caveats

This works in Chrome. I have not tested it in any other browser.

Installation

  1. Copy the exact content of bookmarklet.js to your clipboard.
  2. Bookmark this page to Chrome's Bookmarks Bar
  3. Right-click the bookmark and select "Edit."
  4. Change the new bookmark's name to something like "Markdown Link," and paste to replace its URL with the exact content of bookmarklet.js.
  5. Save the bookmark.

Build Notes

I'm using http://chriszarate.github.io/bookmarkleter/ to convert the script to a bookmarklet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment