Skip to content

Instantly share code, notes, and snippets.

@megahbite
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save megahbite/c4e34f24c0827ccd820c to your computer and use it in GitHub Desktop.
Save megahbite/c4e34f24c0827ccd820c to your computer and use it in GitHub Desktop.
NZIFF add to calendar script
// ==UserScript==
// @name NZIFF 2014 Google Calendar Button
// @description Adds a button to the NZ International Film Festival wishlist items to add them to Google Calendar
// @downloadURL https://gist.githubusercontent.com/megahbite/c4e34f24c0827ccd820c/raw/nziff_calendar.user.js
// @include http://www.nziff.co.nz/2014/*/wishlist/*
// @include http://www.nziff.co.nz/s/*
// @namespace https://github.com/megahbite/
// @require //cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js
// @version 1.0b2
// ==/UserScript==
$('.user-session-list-table').each(function (n, i) {
var session = $(i);
var timestamp = $('.label time', session).attr('datetime');
timestamp = Number(timestamp);
timestamp *= 1e3;
var date = new Date(timestamp);
var title = $('.session-info .title', session).text();
var cinema = $('.session-info .meta span[itemprop=location]', session).text();
var actionsSection = $('.actions', session);
actionsSection.append('<div class="btn btn-sml btn-action">' +
'<a target="_blank" href="http://www.google.com/calendar/event?action=TEMPLATE&text='+ encodeURI(title) +
'&dates='+ date.toString('yyyyMMddTHHmmss') +'/'+ date.toString('yyyyMMddTHHmmss') +
'&location='+ encodeURI(cinema) +'">' +
'Add to Google Calendar' +
'</a>' +
'</div>');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment