Obsidian-bookmarklet
参照中ページのタイトル、URLと選択されているテキストをObsidianのデイリーノートへ追記するブックマークレット(ファイル名を変更するか問われる問題がある)
code:urltitle.js
javascript: (function () {
// URLとタイトルを取得しMarkdown形式のリンクを生成
function urlTitle() {
var text = "+ document.title + "(" + document.URL + ")";
var s = window.getSelection();
if (s.toString().length > 0 ) {
text = text + '\n' + s;
}
return text;
}
// デイリーノートのファイル名 YYYY/MM/YYYY-MM-DD
function fileName(date) {
var yyyy = date.getFullYear().toString();
var mm = (date.getMonth()+1).toString();
var dd = date.getDate().toString();
var mmChars = mm.split('');
var ddChars = dd.split('');
var month = (mmChars1?mm:"0"+mmChars0); return yyyy + '/' + month + '/' + yyyy + '-' + month + '-' + (ddChars1?dd:"0"+ddChars0); }
const file = "_Journal/" + fileName(new Date()) + ".md";
const content = "\n" + urlTitle() + "\n";
//const vault = "content";
document.location.href = "obsidian://new?"
// + 'vault=' + encodeURIComponent(vault)
+ "file=" + encodeURIComponent(file)
+ "&content=" + encodeURIComponent(content)
+ "&append";
})();