Skip to content

Instantly share code, notes, and snippets.

@totomz
Last active February 5, 2021 20:45
Show Gist options
  • Save totomz/dd74e72e34fb14ad11d921aaa4c96036 to your computer and use it in GitHub Desktop.
Save totomz/dd74e72e34fb14ad11d921aaa4c96036 to your computer and use it in GitHub Desktop.
FOSDEM2GCal - Tampermonkey/Greasemonkey script to save FOSDEM event in Google Calendar
// ==UserScript==
// @name FOSDEM2GCal
// @namespace https://github.com/totomz
// @version 0.1
// @description Add talks to your google calendar
// @author Tommaso Doninelli
// @match https://fosdem.org/2021/schedule/event/*
// @grant GM_xmlhttpRequest
// @require https://code.jquery.com/jquery-3.5.1.slim.min.js
// ==/UserScript==
/*
README
*/
(function() {
'use strict';
const start = $('li:contains("Start") > a').attr('title').replaceAll("-","").replaceAll(":","").split("+")[0];
const end = $('li:contains("End") > a').attr('title').replaceAll("-","").replaceAll(":","").split("+")[0];
const video_qa = $('li:contains("Video with Q&A") > a').attr('href');
const video_only = $('li:contains("Video only") > a').attr('href');
const title = $('#pagetitles > h1').text();
const subtitle = $('#pagetitles > h2').text();
const abstract = $('.event-abstract').text();
const description = encodeURIComponent([`Video with Q&A: ${video_qa}`, `Video only: ${video_only}`, ' ', subtitle, ' ', `Event Link: ${window.location.href}`].join("\n"))
const link = `https://www.google.com/calendar/render?action=TEMPLATE&text=[FOSDEM] ${title}&details=${description}&location=&dates=${start}/${end}&ctz=CET`;
$('ul.side-box').prepend(`<li><i class="icon-calendar"></i> <strong>Google Calendar</strong>: <a target="_blank" href="${link}">Save</a></li>`)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment