Open Google Calendar PageMenu
2021-05-01
16:50:54 /u/1
だとなぜかMobile appを開いてくれないので、 render
にした
script.jsconst zero = (n) => `${n}`.padStart(2, "0");
scrapbox.PageMenu.addMenu({
title: 'Open Google Calendar',
image: 'https://upload.wikimedia.org/wikipedia/commons/a/a5/Google_Calendar_icon_%282020%29.svg',
onClick: () => {
const now = new Date();
const [
,
years,
months,
date,
] = scrapbox.Page.title.match(/日刊記録sheet (\d{4})-(\d{2})-(\d{2})/) ?? [
,
now.getFullYear(),
now.getMonth() + 1,
now.getDate(),
];
window.open(`https://calendar.google.com/calendar/${
/mobile/i.test(navigator.userAgent) ? "render" : "u/1"
}/r/week/${zero(years)}/${zero(months)}/${zero(date)}`);
},
});
別のpage menuに入れるとき用
pageItem.jsexport function addGoogleCalendarItem(name) {
scrapbox.PageMenu(name).addItem({
title: 'Open Google Calendar',
image: 'https://upload.wikimedia.org/wikipedia/commons/a/a5/Google_Calendar_icon_%282020%29.svg',
onClick: () => window.open('https://calendar.google.com/calendar/u/1'),
});
}