Skip to content

Instantly share code, notes, and snippets.

@ajsharma
Forked from deenseth/gist:1514633
Created September 14, 2012 22:02
Show Gist options
  • Save ajsharma/3725207 to your computer and use it in GitHub Desktop.
Save ajsharma/3725207 to your computer and use it in GitHub Desktop.
Add Google Calendar Event Bookmarklet
javascript: var s;
/*Figure out the selected text*/
if ( window.getSelection ) {
s = window.getSelection();
} else if ( document.getSelection ) {
s = document.getSelection();
} else {
s = document.selection.createRange().text;
}
/*If there isn't any text selected, get user input*/
if ( s == '' ) {
s = prompt('QuickAdd');
}
var re = RegExp( '[AaPp][Mm]' );
if ( encodeURIComponent(s).match(re) ) {
} else {
var d = new Date();
var hr = d.getHours();
var min = d.getMinutes();
if (min < 10) {
min = "0" + min;
}
s = s + " " + hr + ":" + min; /*if there isn't an AM or PM in the text, add the default current time*/
}
void(
/*open a new window with this information in the Google Calendar event creation page.*/
window.open(
encodeURI('http://www.google.com/calendar/event?ctext='+s+'&action=TEMPLATE&pprop=HowCreated:QUICKADD'),
'addwindow',
'status=no,toolbar=no,width=520,height=470,resizable=yes'
)
);
@AdKiller
Copy link

It seems Google has made it so that this bookmarklet does not work anymore while browsing mail.google.com, it works if you are browsing any other website.
Tried using Firefox v55.0.3, new profile, all default settings.

It would be highly appreciated if you could fix this useful bookmarklet @ajsharma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment