Googleカレンダー URLパラメータ メモ
概要
毎朝、Googleカレンダーを開いて「タイトルに今日の日付」「終日の設定」「公開設定を非公開」「本文の箇条書きボタンを押す」といった具合の操作を行なっていました。
毎日やるのめんどくさいなと思い調べたら、URLパラメータで初期値を付けて予定作成ページを開けるようです。最終的にこのURLを生成するブックマークレットを作成し、ボタンひとつで雛形を呼べるようになった。その時のメモ
公開設定をURLパラメータから指定できなかった為、デフォルトで非公開設定のマイカレンダーを作成し、そちらに予定を作ることで対応しました
完成品
コード
javascript:(function() {
const calendar_id = 'カレンダーID(アカウントに見つからない場合、自動でデフォルトカレンダーに)';
const today = new Date();
const year = today.getFullYear();
const month = ('0' + (today.getMonth() + 1)).slice(-2);
const day = ('0' + today.getDate()).slice(-2);
const dateString = year + '/' + month + '/' + day;
const url = 'https://calendar.google.com/calendar/r/eventedit?' +
'text=' + encodeURIComponent(dateString) +
'&dates=' + year + month + day + '/' + year + month + day +
'&details=' + encodeURIComponent('<ul><li>*</li></ul>') +
'&src='+calendar_id;
window.open(url, '_blank');
})();
登録方法
ブックマークの追加 → 任意の名前&上記のコードをURL欄に貼り付ける → クリック
実行結果
Googleカレンダー URLパラメータ
BaseURLについて
基本的にはhttps://calendar.google.com/calendar/r/eventedit
を利用してください。
https://calendar.google.com/calendar/render
, http://www.google.com/calendar/event
を利用する場合は後述のactionパラメータを付与することで利用できます。
パラメータ
アクション / action
フォーマット : TEMPLATE (固定)
https://calendar.google.com/calendar/render?action=TEMPLATE
テキスト / text
フォーマット : 文字列
https://calendar.google.com/calendar/r/eventedit?text=日報
日付 / dates
フォーマット : YYYYMMDDTHHmmSSZ/YYYYMMDDTHHmmSSZ
https://calendar.google.com/calendar/r/eventedit?dates=20250125T130000Z/20250125T140000Z
# 終日
https://calendar.google.com/calendar/u/0/r/eventedit?dates=20250125/20250126
日付のみで同日または前後日を指定した場合、終日チェックが自動でつきます。
タイムゾーン / ctz
フォーマット : タイムゾーン名
https://calendar.google.com/calendar/r/eventedit?ctz=Asia/Tokyo
詳細 / details
フォーマット : 文字列
https://calendar.google.com/calendar/r/eventedit?details=日報の詳細内容
場所 / location
フォーマット : 文字列
https://calendar.google.com/calendar/r/eventedit?location=東京都渋谷区
予定の状態 / crm
フォーマット : AVAILABLE, BUSY, BLOCKING
https://calendar.google.com/calendar/r/eventedit?trp=BUSY
外部公開設定 / trp
フォーマット : true,false
https://calendar.google.com/calendar/r/eventedit?trp=false
動作が確認できませんでした。壊れているっぽい
イベントソース / sprop
フォーマット : key:value (複数指定可能)
key :
https://calendar.google.com/calendar/r/eventedit?sprop=website:www.example.com&sprop=name:日報システム
表示上には影響出ません。API経由で取れるデータのsrc
ゲスト / add
フォーマット : カンマ区切りのメールアドレス
https://calendar.google.com/calendar/r/eventedit?add=user1@example.com,user2@example.com
繰り返し / recur
フォーマット : RFC-5545仕様のテキスト
https://calendar.google.com/calendar/r/eventedit?recur=RRULE:FREQ=DAILY
カレンダーの指定 / src
フォーマット : メールアドレス
https://calendar.google.com/calendar/r/eventedit?src=beb5cfe709660c0aeb9ee44acbf8772b6253a79272600a0d4f9c34c172d80615@group.calendar.google.com
カレンダーのIDを指定することで、予定の登録先カレンダーを選択できます。
関節的に公開設定やデザインの指定を行うことが可能です。