DEV Community

Cover image for Import a Garoon Event to Google Calendar Bookmarklet
ahandsel
ahandsel

Posted on • Originally published at github.com

Import a Garoon Event to Google Calendar Bookmarklet

Import a Garoon Event to Google Calendar Bookmarklet

Usage

Initial Setup

  1. Copy the below Garoon_to_Google_Bookmarklet.js code block
  2. Go to Bookmark manager (chrome://bookmarks/) > Click on the at the top-right-corner
  3. Click Add new bookmark & paste the code in the URL field

Importing a Garoon Event to Google Calendar

  1. Go to the Garoon event's page
  2. Click on the Bookmark
  3. Confirm the imported event in Google Calendar & click Save

Not working? 🤔

  • Open browser console
    • Mac: Command+Option+C
    • Windows, Linux, Chrome OS: Control+Shift+C
  • Check if you are getting an error message

Garoon_to_Google_Bookmarklet.js

javascript: (() => { const formatTimestamp = (dateString) => new Date(dateString).toISOString().replaceAll(/[-:]|\.\d+/g, ''); const bodyFormat = (inputText) => inputText.replace(/\n/g, '<br>'); const addCalendar = (event) => { console.log({ event }); const start = formatTimestamp(event.start.dateTime); const end = formatTimestamp(event.end.dateTime); const origin = location.origin.replace('.s.', '.'); const url = `${origin}${location.pathname}?event=${event.id}`; const body = bodyFormat(event.notes); const params = new URLSearchParams({ action: 'TEMPLATE' }); params.set('dates', `${start}/${end}`); params.set('text', event.subject); params.set('location', url); params.set('details', body); open(`https://www.google.com/calendar/render?${params.toString()}`); }; const event = window.garoon?.schedule?.event?.get(); if (event === undefined) { alert( `Error: Not on a Garoon event.\nPlease open a specific Garoon event.` ); return; } addCalendar(event); })(); 
Enter fullscreen mode Exit fullscreen mode

References

Top comments (0)