-1

I am making a Chrome extension to work with Google Calendar and I wonder if it possible to instigate Google's own new event dialog (as per the image below) programmatically in JavaScript using the calendar API? If I could set what date was displayed too, that would be even better.

enter image description here

After lots of experimentation, I found that I can go to a URL like this:

https://calendar.google.com/calendar/u/0/r/eventedit?dates=20230329T220000Z/20230329T220000Z

and this will be the "more options" version of the dialog in the picture - you can modify the start/end date in the URL and the dialog will change accordingly. I'd still prefer the simpler dialog.

...and more details in this old SO question but still no info about getting the simpler dialog.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Mick
  • 8,284
  • 22
  • 81
  • 173

1 Answers1

0

Since you are writing an extension, and you can read what the user sees, one way to trigger the popup is:

  • Go to the monthly calendar view.
  • Find the basic grid (in my case, identified by id=YPCqFe)
  • Do some calculation to find the proper cell to click (they use attribute "data-datekey").
  • Fire a click event on it.

Basic example with hardcoded values, try it in your own console after replacing "YPCqFE":

document.getElementById("YPCqFe").children[0].children[1].children[0].children[1].children[4].children[0].click()

TylerH
  • 20,799
  • 66
  • 75
  • 101
pkExec
  • 1,752
  • 1
  • 20
  • 39
  • Not a bad thought and I will investigate that approach some more - however my Chrome extension mainly concerns the "schedule" view which could make things trickier. – Mick Mar 23 '23 at 13:10