DEV Community

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

Posted on • Updated on • Originally published at github.com

Import a Garoon Event to Outlook Calendar Bookmarklet

Garoon Event to Outlook Calendar Bookmarklet

Usage

Initial Setup

  1. Copy the below Garoon_to_Outlook_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 Outlook Calendar

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

Using Outlook Live or Office 365?

Outlook Live and Office 365 uses a different domain so please change the URL accordingly.

Outlook Live:

  • URL: https://outlook.live.com/calendar/deeplink/compose
  • Code: open(`https://outlook.live.com/calendar/deeplink/compose?path=/calendar/action/compose&${params.toString()}`);

Office 365:

  • URL: https://outlook.office.com/calendar/deeplink/compose
  • Code: open(`https://outlook.office.com/calendar/deeplink/compose?path=/calendar/action/compose&${params.toString()}`);

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_Outlook_Bookmarklet.js

javascript: (() => {
  const formatTimestamp = (inputDateString) => {
    const inputDate = new Date(inputDateString);
    const year = inputDate.getUTCFullYear();
    const month = String(inputDate.getUTCMonth() + 1).padStart(2, '0');
    const day = String(inputDate.getUTCDate()).padStart(2, '0');
    const hours = String(inputDate.getUTCHours()).padStart(2, '0');
    const minutes = String(inputDate.getUTCMinutes()).padStart(2, '0');
    const seconds = String(inputDate.getUTCSeconds()).padStart(2, '0');
    const outputDateString = `${year}-${month}-${day}T${hours}:${minutes}:${seconds}Z`;
    return outputDateString;
  };
  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 params = new URLSearchParams({ rru: "addevent" });
    const body = bodyFormat(event.notes);
    params.set("startdt", start);
    params.set("enddt", end);
    params.set("subject", event.subject);
    params.set("body", body);
    params.set("location", url);
    open(`https://outlook.office.com/calendar/deeplink/compose?path=/calendar/action/compose&${params.toString()}`);
  };

  const event = window.garoon?.schedule?.event?.get();

  if (event === undefined) {
    alert(
      `Error: Not on a Garoon schedule.\nPlease open a specific Garoon event.`
    );
    return;
  }

  addCalendar(event);
})();
Enter fullscreen mode Exit fullscreen mode

References

Top comments (0)