9

I am creating a Google Chrome extension for Google calendar. I want to get the ID of an event when user visits the event edit page.

How can I get the event ID from the plugin's javascript code so that I can fire Calendar api v3.0 with that ID.

enter image description here

Adding extra info: Google Calendar API calendar id and event id The comment by @krishna actualy shows how to get the event ID and it works. But how to get the event ID in https://www.google.com/calendar/ URL not in the URL(https://www.google.com/calendar/render?gsessionid=OK&eventdeb=1) as told by Krishna.

Community
  • 1
  • 1
Hari Das
  • 10,145
  • 7
  • 62
  • 59
  • You need to show your research first. I assume you already searched incthe DOM and such. – Zig Mandel May 27 '14 at 13:50
  • I have tried to search in their DOM but only found data-eid. This is not the event ID. Event ID is something different. You can see above image what I found. – Hari Das May 27 '14 at 14:25

1 Answers1

16

It's in the data-eid attribute that you partially covered in black in the screenshot. It is encoded along with other things as base64 (or base64url).

The following code should decode, extract, and print the event ID (assuming jQuery was loaded):

var encoded = $("div.ep[data-eid]").attr("data-eid");
if (encoded !== undefined) {
  var decoded = atob(encoded);
  console.log("Current event ID: " + decoded.split(" ")[0]);
}

prints something like:

Current event ID: 75v3thapnpd234ocglgk625frc
Martin Jambon
  • 4,629
  • 2
  • 22
  • 28