📎

そのページ、マークダウンのリンクでほしくない?

2023/09/16に公開

なにができるの?

開いているページの情報を [タブ表示文字](https://url) の形式でクリップボードにコピーできるようになります 📎

使い方

以下のコードを好きな名前でブックマークに登録して、Markdown形式でコピーしたいページで実行します 🚀

javascript:(function() {

function copyToClipboard(text) {
    if (window.clipboardData && window.clipboardData.setData) {
        /*IE specific code path to prevent textarea being shown while dialog is visible.*/
        return clipboardData.setData("Text", text);

    } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
        var textarea = document.createElement("textarea");
        textarea.textContent = text;
        textarea.style.position = "fixed";  /* Prevent scrolling to bottom of page in MS Edge.*/
        document.body.appendChild(textarea);
        textarea.select();
        try {
            return document.execCommand("copy");  /* Security exception may be thrown by some browsers.*/
        } catch (ex) {
            console.warn("Copy to clipboard failed.", ex);
            return false;
        } finally {
            document.body.removeChild(textarea);
        }
    }
}

var markdown = '[' + document.title + '](' + window.location.href + ')';
copyToClipboard(markdown);
})();

原典は以下のページから

https://gist.github.com/bradleybossard/3667ad5259045f839adc

どうやって?

JavaScriptをブラウザのブックマークに登録して、閲覧中のページで実行できる機能である Bookmarklet を使っています ✨

Tips 💪

Vimiumとの組み合わせ

Vimium と組み合わせると、b ボタンからブックマークを選択できるのでキーボード操作のみで実行できます ✨
これ以外にもものすごく便利な機能があるので、ぜひ使ってみてください

Slackで使う

Slackのテキストボックスにペーストしてから Ctrl+Shift+F を押すとmd形式のドキュメントがフォーマットされて文字列がリンクになるのでチームメンバーとの共有に便利です ✨

GitHubで編集を提案

Discussion