選択日時をGoogleカレンダーに追加するブックマークレット

下のjavascriptをお気に入りやリンクバーなどに登録して、リンクしたいページでクリック。

javascript:(function(){F=function(v){return%20(v<10?'0':'')+v;};DF=function(r){var%20hh=r.getHours();var%20mm=r.getMinutes();var%20ss=r.getSeconds();return%20F(r.getFullYear())+F(r.getMonth()+1)+F(r.getDate())+(hh+mm+ss>0?'T'+F(hh)+F(mm)+F(ss):'');};R=function(v){return%20v.replace(/[%EF%BC%90-%EF%BC%99%EF%BC%8F%EF%BC%9A]/g,function%20($0){return%20String.fromCharCode($0.charCodeAt(0)-65248);}).replace(/[%E5%B9%B4%E6%9C%88]/g,'/').replace(/[%E6%99%82]/g,':').replace(/[^0-9:\/%EF%BD%9E]+/g,'%20');};D=function(v){if(isNaN(new%20Date(v))){v=new%20Date().getFullYear()+'/'+v;}else%20if(v.match(/^\d\d[^\d]/)){v='20'+v;}return%20new%20Date(v);};var%20t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange().text));var%20s=String(t).split('%EF%BD%9E');var%20m=t+'\n'+location.href;var%20d='';if(!isNaN(D(R(s[0])))){m=location.href;d='&dates='+DF(D(R(s[0])))+'/'+DF(D(R(s[s.length-1])));}var%20w=window.open('https://www.google.com/calendar/event?action=TEMPLATE&text='+escape(document.title)+'&details='+escape(m)+d,'_blank');})()
  • 日時の間に「〜」が含まれていたら期間になる
  • 日にちのみ選択されていたら終日
  • 今のところFirefox専用
  • カレンダーのタイトルに、開いているページのタイトルを利用
  • 詳細に開いているページのURLを利用
  • 事前にGoogleカレンダーにログインしておくといいよ

ためしにe+でMr.ChildrenのプレオーダーをGoogleカレンダーに登録してみる

こんな感じの日付っぽいところで・・・

日時を適当に選択する

ブックマークレットのリンクをクリックすると、以下の画面が起動する(はず)

できた!

いまのところIEで動かないので、誰か動くようにしてくれるとうれしいと思います(他力本願)