Skip to content

Instantly share code, notes, and snippets.

@erikig
Last active April 22, 2023 04:06
Show Gist options
  • Save erikig/783b71ea2d704f7dd86e0403bbb5a53a to your computer and use it in GitHub Desktop.
Save erikig/783b71ea2d704f7dd86e0403bbb5a53a to your computer and use it in GitHub Desktop.
Add to Google Calendar
/*
How to use:
1. Open Chrome
2. New Bookmark
3. Enter Name - https://emojipedia.org/search/?q=calendar
4. Paste code below into URL field
*/
javascript: (function() {
var title = encodeURIComponent("Follow Up - " + document.title.replace("Account > ",""));
var location = encodeURIComponent(window.location.href);
var description = encodeURIComponent("Link: " + window.location.href + "\nAdditional Notes Here");
var defaultStartDate = new Date(new Date().getTime()+86400000); /* 24hrs from now */
var defaultEndDate = new Date(new Date().getTime()+86400000+900000); /* 15 mins later */
var formatDate = function(d){ return encodeURIComponent((d).toISOString().replace(/\.\d\d\dZ/,"Z").replace(/-|\:|\./g,"")) }; /* YYYYMMDDToHHMMSSZ Format */
var url = `https://www.google.com/calendar/render?action=TEMPLATE&dates=${formatDate(defaultStartDate)}/${formatDate(defaultEndDate)}&text=${title}&details=${description}&location=${location}`;
/* console.log(url); */
/* calWindow = window.open(url); */
calWindow = window.open(url,"calWindow","width=1200,height=800,location=yes,scrollbars=yes,menubar=no,toolbar=no,titlebar=yes")
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment