Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/* Org-mode 用参照情報付き Quote ブロック生成ブックマークレット
*
* WDF - Software : ブックマークレット作成スクリプト - http://www.eonet.ne.jp/~wdf/software/bookmarklet_creator.html
*/
javascript: (function(d) {
var selected = d.selection ? d.selection.createRange().text : d.getSelection();
var dt = new Date();
/*空白スペースは予め に置換しておく*/
var block = "#+BEGIN_QUOTE\n" + selected + "\n#+END_QUOTE\n#+CITE: ";
var dt = new Date();
var cite = "{";
cite += "\"type\": \"web\", ";
cite += "\"title\": \"" + d.title + "\", ";
cite += "\"url\": \"" + window.location.href + "\", ";
cite += "\"accessed\": \"" + dt.toLocaleString() + "\"}";
/* クリップボードに文字列をコピー*Clipboard APIはまだ実験段階の機能**参考*-JavaScriptプログラミング講座【Clipboard APIについて】-https://goo.gl/CbMM2f*-document.execCommand('copy')してみる-Qiita-https://goo.gl/yvGlD5 */
var body = document.body;
var text_area = document.createElement("textarea");
text_area.value = block + cite;
body.appendChild(text_area);
text_area.select();
var result = document.execCommand("copy");
body.removeChild(text_area);
})(document)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment