Extra caution is recommended when installing recently uploaded/updated scripts (read more)
Be sure you trust any scripts you install

GCal Event Color Codes

Color codes GCal events using tags and get time summaries by tag. (Allows multiple colors on one calendar)

This script creates an expandable box between the month and the calendar list on the left side. Clicking the button on this box toggles the display between a user selected color coding, based on tags in the event title, and the default Gcal, per calendar, color coding. The script searches for events the contain a tag such as "!fun" or "!work" and colors the event based on the table of colors defined in the script. (Tags are indicated by a leading "!" or "#", as indicated by the script menu option) You can also define subtags, which are key words which map to a tag if no tag is explicitly specified. (eg. "dinner" and "lunch" might be subtags of "!food" so you don't have to type the tag every time you create an event labeled "dinner".)

The default tags defined are just the author's personal categories; you can easily modify the list with your own preferred tags and colors by editing the colors array at the top of the script.

The format is: [tag,border color,body color, [subtag1, subtag2,...]]
Ex: ["travel","rgb(108,148,118)","rgb(148,188,158)", ["trip","flight"]]

Clicking the arrow on the box expands the box to show a list of your tags and the time (in hours) for each tag on the calendar.




Updates
06/22/08 - Fixed to support updated GCal source
05/28/08 - Added Time summarization by tag and "subtags",Fixed to support updated GCal source
04/02/08 - Fixed to support updated GCal source
02/19/08 - Fixed to support updated GCal source
01/12/08 - Refactored code and made on/off state persistent on refresh
12/28/07 - Fixed to support updated GCal source
11/11/07 - Fixed to support updated GCal source, added support for all day events
10/24/07 - Fixed to support updated GCal source
09/23/07 - Refactored code and added menu option to choose "!" or "#" as the tag prefix
09/09/07 - Fixed to support updated GCal source
16/07/07 - Fixed refresh bug
15/07/07 - Fixed to support updated GCal source
23/06/07 - Added support for gcal over SSL




Jun 22, 2008
Matthew Jeff... Script's author

@jesa: month view uses a different page structure from daily and weekly views, so for now the script ignores month view. If it's something people would really like to see I could work on supporting it.

 
Jun 19, 2008
jesa User

This script is exactly what I was looking for - thanks. I'm wondering though if it should work for the month view - I can only get it to work for the weekly view. Thanks

 
Apr 2, 2008
Matthew Jeff... Script's author

Thanks Dogwalker.

Sorry to anyone who was waiting for a long time for me to get in the change. Every time google updates their javascript, the funtion name changes, breaking the script.

@bobielawlintine: The recent security update for greasemonkey broke my system for storing your prefrences over a refresh. I'll try to get a fix in soon, but for now you can open about:config and change the value of the key with a name like this:
greasemonkey.scriptvals.http://www.hmc.edu/~mjeffryes/GCal Event Color Codes.is_on
to true to have the color codes stay on when you refresh the page

 
Mar 13, 2008
Dogwalker User

Update the Code urself:

Open the Code
1. Tools -> Greasemonkey -> Manage user Scripts...

2. Choose Gcal Event Color Codes
3. Click "Edit" Button
4. On the code search for:".gt"
5. Replace it for:".Ft"

It should be
unsafeWindow.gccc = new GCalColorCoder('gccc',unsafeWindow.Ft, rhook);
unsafeWindow.Ft = unsafeWindow.gccc.color_hook

 
Feb 29, 2008
bobielawlintine Scriptwright

#Using Bugmenot account!

Nice script, i wonder why its not keeping my preference to keep it always On!
Anything i can change in the code to get it Always ON?

 
Jan 13, 2008
CyberCPA Scriptwright

Nope, no luck. Changing the include pattern does not make it work for me. Bummer!

 
Jan 13, 2008
Matthew Jeff... Script's author

@CyberCPA: you might double check that the @include patterns match the url for your google calendar. I may not have gotten them all.

 
Nov 12, 2007
Philip Stoever Scriptwright

thanks, works like a charme :)

 
Nov 11, 2007
CyberCPA Scriptwright

I have never been able to get this to work with any events, all day or otherwise. I have tried changing the # and ! characters without any results whatsoever. The calendar still shows events in the default calendar color. I run no other GreaseMonkey scripts with Calendar, so I know it's not a script conflict. I am using the secure connection w/ calendar.

 
Nov 11, 2007
Matthew Jeff... Script's author

There, now all day events should color code just like regular events. Let me know how it works for you.

 
Nov 11, 2007
Matthew Jeff... Script's author

I changed the script to support the new code again. All day events shouldn't be too hard to add, just need to search for a different set of divs.

 
Nov 11, 2007
Philip Stoever Scriptwright

i wonder if it's possible to get the coloring working on the "all day" events, too?

 
Nov 11, 2007
Philip Stoever Scriptwright

it's update time again, the function is called "fc" now

 
Oct 29, 2007
Philip Stoever Scriptwright

Thanks a lot, great work :)

Following your suggestion to crosslink I've uploaded a slightly modified version:

http://userscripts.org/scripts/show/13432

 
Oct 24, 2007
Matthew Jeff... Script's author

Also, for those of you who want to know how to update the script yourself when google updates code, it's not too hard:

- Get a copy of the big Google calender js file with most of the application code using firebug of the like.

- Search the js file for '("eventowner")' space out the function containing the first hit. Looks something like this:

function Wb(a){
try{
if(!mm){
var b=n("eventowner");
if(b){
b.innerHTML=l
}
n("calowner").innerHTML=l;
if((z.V()&1)==0){
n("allDayGrid").style.display=B
}
hd();
eo()
}
if(!Wj){
Xb=[]
}
Yf();
RE();
YE();
ea("refreshMode = "+nm);
if(nm>=100){
WE()
}
if(!a)
VE();
UE();
OE()
}catch(c){
tc(c+"\n\n"+c.stack)
}
}

- Replace the old 2 letter function name with the new function name in the insert and uninsert functions in the color-coding script.

If that sounds like too much work, you can just wait until I post the fix, usually no longer than a few days.

 
Oct 24, 2007
Matthew Jeff... Script's author

Posted a new version which works with the changes in google's code.

Unfortunately, every time google posts a change to their source, their compiler changes all the function names, breaking my hooks which call the coloring code. I love any suggestions for ways to overcome this weakness in the current design.

 
Oct 24, 2007
Philip Stoever Scriptwright

Script ceased to work a few days ago. Google must have changed something.
I think the color() function never gets called. Probably the line

Xb = function(a){oldXb(a); color();};

needs some tweaking but I can't get it to work :-/

 
Sep 11, 2007
Jan Parchmann Scriptwright

Hi Matthew, you can add a menu toggle as setting, so everybody can choose whether she prefers colored or uncolored view as default, and choose between # and !
http://wiki.greasespot.net/Code_snippets#Make_m...

 
Sep 11, 2007
Matthew Jeff... Script's author

Thanks for the comments.
@Philip:
I personally prefer to us "!" but if there are several others who'd like it to be "#" I'll change the code. Since it's just a simple find/replace, it should be easy to use any flag you prefer. I also like to use the button, simply because I occasionally need to flip between comparing calendars and comparing the events in the calendar. Maybe you could post your variation on the script and we could just cross-link them for convenience.

 
Sep 10, 2007
Jan Parchmann Scriptwright

I really missed that in gCal! Great work!

 
Sep 10, 2007
Philip Stoever Scriptwright

Thanks, works great!

I adjusted the script to use "#" instead of "!" as some people tend to use "!" in their descriptions and set the default to show the colored version without having to click the button on every page refresh.

You could comment on this script if you were logged in.