LoginSignup
1
1

More than 5 years have passed since last update.

Safariの選択部分をHTMLごとblockquoteで引用するTextExpander用AppleScript

Last updated at Posted at 2015-12-25
blockquote.scpt
tell application "Safari"
    tell current tab of window 1
        do JavaScript "var htmlText = '';
if (document.selection) {
    var c = document.selection.createRange();
    htmlText = c.htmlText;
} else {
    var nNd = document.createElement(\"div\");
    var sel = getSelection();
    if (sel == null || sel == '') {
        htmlText = '';
    } else {
        var w = getSelection().getRangeAt(0).cloneContents();
        nNd.appendChild(w);
        htmlText = nNd.innerHTML;
    }
}
'<blockquote cite=\"' + location.href + '\" title=\"' + document.title + '\">\\n' + htmlText + '\\n' + '<cite><a href=\"' + location.href + '\" target=\"_blank\">' + document.title + '</a></cite>\\n' + '</blockquote>\\n';"
    end tell
end tell

更新履歴

  • 2012-10-31: Google Chrome版として作成
  • 2015-12-25: Safari版に修正
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1