Edited at

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

More than 3 years have passed since last update.


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版に修正