Skip to content

Instantly share code, notes, and snippets.

@jr-codes
Created August 29, 2012 05:07
Show Gist options
  • Save jr-codes/3507032 to your computer and use it in GitHub Desktop.
Save jr-codes/3507032 to your computer and use it in GitHub Desktop.
Google Calendar Tasks Killer
// ==UserScript==
// @name Google Calendar Tasks Killer
// @namespace http://zarjay.net/
// @description Removes the "Tasks" item from the "My Calendar" section of Google Calendar
// @match https://www.google.com/calendar/*
// @version 1.0
// ==/UserScript==
// Removes the "Tasks" item from "My Calendar"
function killTasks() {
var tasksLabel = document.getElementById('label-dGFza3NAdGFza3MuZ29vZ2xlLmNvbQ');
if (tasksLabel) tasksLabel.parentNode.style.display = 'none';
}
// Waits for synchronous code to finish executing before calling killTasks()
function asyncKillTasks() {
setTimeout(killTasks, 0);
}
function init() {
// Kill Tasks!
killTasks();
// Google Calendar will try to bring Tasks back every time you select
// a calendar. This will make sure it stays hidden.
var myCalendars = document.getElementById('calendars_my');
if (myCalendars) myCalendars.addEventListener('mousedown', asyncKillTasks);
var otherCalendars = document.getElementById('calendars_fav');
if (otherCalendars) otherCalendars.addEventListener('mousedown', asyncKillTasks);
}
// Wait a bit before executing (Google Calendar needs some time to load)
setTimeout(init, 1500);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment