This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* JSON 形式の Web サイトの参照情報を作成するブックマークレット | |
* | |
* WDF - Software : ブックマークレット作成スクリプト - http://www.eonet.ne.jp/~wdf/software/bookmarklet_creator.html | |
*/ | |
javascript: (function(d) { | |
/*空白スペースは予めURLエンコードしておく*/ | |
var s = d.selection ? d.selection.createRange().text : d.getSelection(); | |
var dt = new Date(); | |
var cite = "{"; | |
cite += "\"type\": \"web\", "; | |
cite += "\"title\": \"" + d.title + "\", "; | |
cite += "\"url\": \"" + window.location.href + "\", "; | |
cite += "\"accessed\": \"" + dt.toLocaleString(); | |
cite += "\"}"; | |
/* | |
* クリップボードに文字列をコピー*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 = 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