DEV Community

Cover image for Copy as MarkdownLink
Kolja
Kolja

Posted on

Copy as MarkdownLink

Admittedly I am lazy, sometimes very lazy.
But who isn't?

I often insert links to interesting websites in markdown files. For this I always have to copy the link from the address bar and type in the title of the page manually.

But JavaScript and bookmarks are your friend!

Save this code as a bookmark and be as lazy as me:

javascript: (function () {
    var title = document.title;
    var url = window.location.href;
    var textarea = document.createElement('textarea');
    textarea.value = '[' + title + '](' + url + ')';
    document.body.appendChild(textarea);
    textarea.select();
    document.execCommand('copy');
    document.body.removeChild(textarea);
})();
Enter fullscreen mode Exit fullscreen mode

Top comments (0)