Created
December 23, 2011 16:23
-
-
Save deenseth/1514633 to your computer and use it in GitHub Desktop.
Add Google Calendar Event Bookmarklet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
) | |
); |
Use it for work and it's a huge time saver. Thank you for sharing!
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 @deenseth
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey man, your code works but it got a bit of issues. I got "null" if I cancel on the Quick Add prompt.
btw, you can use this page for generating draggable bookmarklet links.
http://pastetool.com/generators/bookmarklet/