diary-button
今日の日付をタイトルとする日記ページを作る
Googleカレンダーベースで動いていたやつを移植してきた
button.jsvar diffDate = function (date, diff) {
// date: '1993-09-11'
// diff: +1, -1
var d = new Date(date);
d.setDate(d.getDate() + diff);
var a = [
d.getFullYear(),
('00' + (1 + d.getMonth())).slice(-2),
('00' + d.getDate()).slice(-2)
];
return a.join('-');
};
const main = function () {
var days = ["日", "月", "火", "水", "木", "金", "土"];
var d = new Date();
var year = d.getFullYear();
var dt = d.getDate();
var month = d.getMonth() + 1;
var date = [
year,
('00' + month).slice(-2),
('00' + dt).slice(-2)
];
var day = days[d.getDay()];
/****** 編集エリア ******/
// お好きなタイトル
var title = date.join('-');
/************************/
var scrapboxProject = location.href.match(/scrapbox.io\/([^\/.]*)/)[1];
var projectUrl = 'https://scrapbox.io/' + scrapboxProject + '/';
var tags = [
'[← ' + projectUrl + encodeURIComponent(diffDate(title, -1)) +']',
'#' + year,
'#' + month + '月',
'#' + day + '曜日',
'[→ ' + projectUrl + encodeURIComponent(diffDate(title, +1)) +']'
];
/****** 編集エリア ******/
// お好きなハッシュタグまたは本文
var body = encodeURIComponent(tags.join(' '));
/************************/
var scrapboxUrl = 'https://scrapbox.io/' + scrapboxProject + '/' + encodeURIComponent(title);
window.open(scrapboxUrl + '?body=' + body);
}
main()