Skip to content

Instantly share code, notes, and snippets.

@reustle
Last active October 18, 2023 05:14
Show Gist options
  • Save reustle/2d52aad253bff55825b2ece58b9829f0 to your computer and use it in GitHub Desktop.
Save reustle/2d52aad253bff55825b2ece58b9829f0 to your computer and use it in GitHub Desktop.
Whova Google Calendar Links

Whova Google Calendar Links

This will go through each of the agenda items in Whova and produce an Add To Google Calendar link.

Usage

Copy / paste the Javascript code below into your browser console once you've logged in.

Found this useful?

Find me ( Shane Reustle ) at the event and ask me about Tech Janitor

const LIST_GOING_ONLY = true;
// Change this to false if you'd like to see all events, instead of
// just those that you've marked as Attending.
function fixDate(dateTimeStr) {
const dateTimeWithTimezone = `${dateTimeStr} UTC+0700`;
const dateObj = new Date(dateTimeWithTimezone);
if (isNaN(dateObj.getTime())) {
return null;
}
return dateObj;
}
function createGoogleCalendarLink(event) {
const baseUrl = 'https://www.google.com/calendar/event?action=TEMPLATE';
const start = new Date(event.start).toISOString().replace(/-|:|\.\d\d\d/g, "");
const end = new Date(event.end).toISOString().replace(/-|:|\.\d\d\d/g, "");
const title = encodeURIComponent(event.title);
const location = encodeURIComponent(event.loc);
const description = encodeURIComponent(event.desc.substring(0, 500));
const calendarUrl = `${baseUrl}&text=${title}&dates=${start}/${end}&details=${description}&location=${location}`;
return calendarUrl;
}
async function grabSessions() {
console.log('Grabbing sessions...');
let userAgenda = await fetch('https://whova.com/webapp/api/agenda/sessions/?event_id=dcbkk_202310');
let agendaDataJson = await userAgenda.json();
let agendaData = agendaDataJson?.result?.sessions;
let sessions = agendaData.map( session => {
return {
going: (session.added === "yes"),
id: session.id,
title: session.title,
loc: session.loc,
start_ts: session.start_ts,
start: fixDate(session.start_ts),
end_ts: session.end_ts,
end: fixDate(session.end_ts),
desc: session.desc,
}
return null;
}).filter(sesh => { return sesh != null })
return sessions.sort((a, b) => a.start - b.start);
}
function printLinks(sessions, options) {
sessions.forEach(session => {
if(options?.goingOnly && !session.going){ return; }
console.log(`%c${session.start_ts} %c- ${session.loc}`, `font-weight: bold; color: #1a60ab`, `font-weight: inherit; color: default;`);
console.log(`${session.title}`)
console.log(createGoogleCalendarLink(session))
console.log('\n')
})
}
let sessions = await grabSessions();
printLinks( sessions, { goingOnly: LIST_GOING_ONLY });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment