A Greasemonkey Christmas #
Update on 1/23/2006: The label colors script exposed a XSS vulnerability. It has now been updated to remove this hole - all users are encouraged to install the latest version of the script.
After many delays, I've finally gotten around to updating my Greasemonkey scripts so that they run under Firefox 1.5 and Greasemonkey 0.6.4. In fact, these scripts will most likely not work in older versions, and I will not be supporting Firefox 1.0.x or Greasemonkey 0.3.x.
Conversation Preview Bubbles (script) was the most straight-forward, since I had already done some work to make it compatible with the unreleased Greasemonkey 0.5.x releases. In fact, it seems to work better under FF 1.5/GM 0.6.4 - before the script did not trigger for label and search results views, but now it does. Saved Searches (script) required a bit more work, and in the process I decided to clean it up a bit. The result count functionality was removed, since it was not that useful. The fixed font toggle feature was spun off into a separate script since it didn't make any sense for it to be bundled.
I'm also taking this opportunity to announce two scripts that I had previously written and never gotten around to releasing. Gmail Macros adds additional keyboard shortcuts to Gmail. Some are obvious (and have been done by other scripts) such as "t" for move to trash and "r" for mark as read. However, I strove to provide a bit more functionality. For example, "p" both marks a message as read and archives it, when you really don't want to read something (the "p" stands for "purge"). Additionally, the shortcuts can be easily customized by editing the HANDLERS_TABLE
constant. More than one action can be chained together by providing a list of action codes (which are contained in the script and were extracted by looking at the generated "More Actions..." menu in Gmail). The other novel feature is for label operations. Pressing "g" brings up a Quicksilver-like display that allows you to begin typing in a label name to go to it (special names like "Inbox" and "Trash" work too). Similarly, pressing "l" allows you to label a conversation with the label of your choosing.
The other script is Gmail Label Colors. In the much-quoted Walt Mossberg article on Gmail and Yahoo Mail, he claims "Gmail doesn't allow folders, only color-coded labels." Ignoring the folders vs. labels debate for now, this sentence is not actually true, since labels in Gmail cannot be color-coded. This script adds that functionality, since it turns out to be very useful (if used sparingly, otherwise too many colors can get overwhelming). To specify a color, simply rename a label to "Labelname #color" (e.g. to make the label "Foo" be red, use "Foo #red" and to make the label "Bar" be orange-ish, use "Bar ##d52"). It works in a similar way to the conversation bubble script, in that it overrides the JavaScript function through which Gmail receives data. It has to jump through some hoops to avoid the HTML escaping that Gmail does; intrepid Greasemonkey hackers may want to look at the source.
If you're wondering why so many of my Greasemonkey scripts are Gmail-related, it's because it's the application where I spend a significant part of my day, thus every bit of productivity improvement counts. Not only do I use Gmail for my personal email, but I also use an internal version for my email needs at Google (as do most of the other Googlers - this constant dog-fooding helps to make Gmail a better product).
(the usual) Disclaimer: I happen to work for Google. These scripts were produced without any internal knowledge of Gmail, and they are not endorsed by Google in any way. If you have any problems with them, please contact only me.
265 Comments
I can't live without the preview bubbles.
Merry Christmas & a Happy New Year :-)
One thing: I personally did like the result count on the saved searches. How difficult would it be to add back in?
Also, can you embelish a little on where you're getting the code d52 from? I am familiar with 6-digit colors only.
Thanks
Luka, I've updated the script so that hitting enter will use the first label that matches, so you can just hit that key after entering "xyz" (the key code works on Mac OS X, not sure about Linux or Windows).
Alex, the 3-digit colors is a shorthand: #abc gets expanded to #aabbcc and so on. Not sure why it wouldn't work for you. Make sure there are no stray spaces.
But it was very easy to change the routine to hard-code my own colors. For example:
function getLabelColorInfo(rawLabelName) {
switch (rawLabelName) {
case "I-CANSLIM": return {name: rawLabelName, color: "green"}; break;
case "I-Investing": return {name: rawLabelName, color: "blue"}; break;
default: return{name: rawLabelName};
}
}
Thanks so much for all the scripts! they're awesome!
Also it would be nice to hide the #color from the label list!
Regards.
I tried changing script with notepad, but it didn't work.
Any ideas?
thanks
KoreV, the key code for 'd' is 68, you can try changing line 49 to that instead of 84.
One addition that I would like to see for gmail (or added via a greasemonkey script) would be archive and go to the next message, and archive and go to the previous message. Likewise, doing a trash this message and go to the next one would also be helpful.
I frequently have 8-10 emails, several of which are generated automatically by my server, and I just need to review last night's data and then can trash the mail. It's slow to keep going back to the inbox and then pick off the next one with a mouse click. I run a Squirrelmail installation and really miss these functions (which are part of Squirrelmail).
I tend to read through a set of messages and when I'm done I select them all and archive. I was planning on figuring out how to do it myself but you've saved me most of the hard work. I'm thinking ma (mark all), mu, mr, ml.
Also, is there some sort of rough programmer's reference to gmail or does everybody writing greasemonkey gmail scripts reverse engineer it themselves?
I don't think anyone has written a reference to Gmail script writing. I usually use some combination of the DOM Inspector[1], JavaScript Shell[2], Web Developer Extension[3] and the handy "View Selection Source" command from Firefox's context menu.
[1] http://www.mozilla.org/projects/inspector/
[2] http://www.squarefree.com/shell/
[3] http://chrispederick.com/work/webdeveloper/
Tip: I also made a Persistent Search that was simply an email of your Gmail Macros list. So, i can quickly reference those shortcuts.
Great Job about all this.
Marry Xmans and Happy New Year!!!
ga
gs
gc
gd
gi
Too bad :(
Script:
http://gr.ayre.st/~grayrest/greasemonkey/gmail/gmail-macros.user.js
Patch:
http://gr.ayre.st/~grayrest/greasemonkey/gmail-macros-select.patch
I'm happy now.
Same urls as before.
how can I edit the script,
thanks
I have tried running the above scripts and my Firefox 1.5 crashes constantly. I really like the label color script, but I can't stand that Firefox crashes every 10 minutes or less.
It'b be usefull.
I don't know how to do it, maybe i can receive advice about doing it.
Thanks
I found the label color and quick silver very useful
thanks a lot.
i installed preview js but whenever i right click i am getting the standard right click menu .
Could you try to make a script which will allow user to attach a note to mail?
I think we can use a mail to make a "note" a script which will tigger a mail to self with the same subject will keep that new mail attached to the conversation.
thanks
sam
http://jeremy.zawodny.com/i/gm-error.png
Any ideas?
So that seems to be a bug.
I had the same error. Do you have the Firefox Gmail Delete extension installed? I read somewhere it doesn't place nice with Greasemonkey. I removed it and now could install the scripts fine.
http://greaseblog.blogspot.com/2005/12/troubleshooting-064.html
It may help.
That said, LOVVVVVE the script.
A couple of points though.
I agree with Not Shitashi that the labels thing takes a bit of getting used to. It's so easy to just type in the wrong thing and suddenly it selects that one and, OMG where did it go?!? ;) Ideally, could the Quicksilver thing show a list of labels that match the text that you type in? So for example, I have a label that says "Google", and another for Gigs And Tours. If I type "G", then it'd show those two (and perhaps a third option for "Create New Label") in a list, allowing me to select one. Or alternatively, just requiring me to press enter after typing the label name would be good too.
Secondly, I noticed a possible bug in the previews script. If I right click a message that has HTML in it, WITHOUT selecting it first with the tickbox, the preview window appears very tall and thin, meaning I have to scroll horizontally in order to read it all. I managed to test this with emails from BOL.com and theonion.com.
I'll have a look at the script for the labels one to see if I can make it need an enter to close.
Anyway, cool scripts. Cheers
Basically, what was causing the quicksilver window to disappear as soon as it found a match was that it was calling the endLabalAction as soon as selectedLabels had more than 0 elements OR someone pressed enter.
I've removed the check for 0 elements so it now waits for you to press enter.
function updateLabelAction(event) {
//...snip...
if (event.keyCode == 40) {
// Tell the user what we picked
banner.update(selectedLabels[0]);
}
// We don't invoke the action straight away, if the user wants to keep
// typing and/or admire the banner
if (event.keyCode == 13) {
dispatchedActionTimeout = window.setTimeout(
function () {
activeLabelAction(selectedLabels[0]);
endLabelAction();
}, 400);
}
}
You can press the down arrow to show the match, and up to get back to what you were typing. That's what the check for keycode 40 is for. I'm actually in two minds as to whether it should just show a match as soon as it finds one, so if you want it to do that, just remove the if (event.keyCode == 40) statement.
Anyway, now I'm a lot happier. Thanks
Cheers
Karl, I like your changes, but I have some issues. "?" doesn't do anything for me (on Mac, haven't tried on other platforms). Also, with your changed macro script, when hitting "/", it focuses the search field, but also adds "/" in the field. This doesn't happen with mihai's original macro script.
But absolutely a must have set of extensions! Keep it coming!
It could also be another of my extensions since I updated a couple. DuplicateTab also broke but worked fine after reinstalling.
Finally, it could be some change in GMail that stopped all of them from working.
Anyone else found this issue?
I appreciate all of the hardwork to make these scripts. Even though I had problems with one of them, the others seem to work fine.
I'm a newbie to scripts. I've downloaded the latest Greasemonkey and FF and the scripts, I can't replicate the colored bubble labels on the second pic ("Receipts" in red and "persisten.info" in beige). I've read the article and skimmed the comments with no success.
Help?
From "gmail team "...- using certain browser extensions that change the behavior of a website
(Greasemonkey, a popular Firefox extension, often interferes with Gmail.
We suggest disabling Greasemonkey to use Gmail without any issues.)
For your protection, we ask that you disable any non-supported software
before accessing Gmail again."
When using O to expand all in conversation mode a bug seems to occur that traps the focus. I often have really long conversations (one of the great features of gmail) and it is nice to have your shortcut to expand the thread. When just clicking the Expand all/Collapse all, the navigation keys work fine (try clicking expand all and then using pgdown. at this point gmail shortcuts work fine too). When using the O key to expand all, the navigations keys stop working until the focus is properly restored. With my limited investigative powers I discovered the following. Clicking on the little colored box in the lower right corner fixes the problem. I can then use arrows and pgup/down to navigate. It seems that perhaps the conversation view has something that is trapping keys and makes it so your fakeMouseEvent doesn't work quite right. Thanks for any insight. I am looking into the code now, but I am very bad at DHTML stuff and javascript.
https://mail.google.com/support/bin/answer.py?answer=6594
the regular shortcuts should suffice.
I have one query. In the gmail-macros.user.js, I can see "REMOVE_LABEL" const, but not it's usage anywhere in the script. How to give a shortcut for it ?
steps:
1. inbox is opened
2. by keyboard, i mark some mails with 'x' key
3. then use 'l' key to lable them
4. hey ! I labled them wrong
5. ok no problem as they are still marked
6. I press again 'l' and select same lable, to "UNLABLE" them,
7. this I intend to do, but they are not unlabled
query:
what key shd I press to unlable them ? pl note that I am at inbox still and 'y' key will archive them.
This macro script has helped me a LOT, as I am a keyboard feak, but this one seems to be eluding me.
I am using Firefox 1.5.0.1.
Help ...
(I used to edit userCSS directly, but was told that your script is much better.)
'Toggle font' text on right side below 'Expand all' in message view.
Any chance of getting you to update your bloglines to del.icio.us greasemonkey script? I just found it last night and it doesn't seem to be working. I assume it's because of the same greasemonkey upgrade. Or are you going to tell me to go use Google Reader?
Thanks for the cool scripts.
Gmail Label Colours
Firefox 1.5
Windows XP Pro
In any mailbox (not in message view), when a message with a coloured label is selected, the "More Actions..." Menu, under "Remove label:", has the label's name option coloured. (This is actually nice.) The problem is that when it is selected, the message at the top reads (as an example):
The label "Debate" has been removed from the conversation. Learn more
but the label is not removed. Hope this helps. If you need any more info, email me at [email protected]
Thanks for all the great extensions.
The label "Debate" has been removed from the conversation. Learn more
The label "[opentag]!-- f4ec7d7f501a61a5-108fa49449e NES --[closetag][opentag]span style="background: #900" class="colored"[closetag]Debate[opentag]/span[closetag][opentag]!-- f4ec7d7f501a61a5-108fa49449eNEE --[closetag]" has been removed from the conversation. Learn more
Thank you soooo much for this GREAT functionality!
Thanks a million!
I still haven't figured out how to implement a "remove label" hotkey though. If anyone has managed to do it, please e-mail me or post the solution here.
BTW, if you donot make any lable starting with "i", then pressing "gi" will take you to inbox. the latest script has this feature.
If you read the first message in your inbox, and send a reply, then return to the inbox, right clicking for the preview bubble on the second message brings up the reply to the first message. Right clicking on the third message brings up the second message, etc. If you refresh Gmail, everything goes back to normal.
Thanks for all the great extensions, hope this helps.
I am unable to use the Gmail Labels from today morning ? The quick silver doesn't show up even when I press "g". Is something changed, can you fix it. Got so used to it, I am unable to use gmail now :(
Cheers,
v
and Going to Chats... ooh, that'd be icing on the cake
Any help how to enable it.
And yes, it stopped working for me too. I'm completely lost.
Find/Replace "tamu" with "tam" (%s/tamu/tam/g)
Or here's a patch [http://www.christilden.com/gmail-macros-fix20060316.patch].
http://www.christilden.com/gmail-macros-fix20060318.patch
I want to use 'Q', so I added
--> 81: [MARK_AS_UNREAD], // Q: mark as unread
to the cont HANDLERS_TABLE.
The script comes with the predefined const MARK_AS_UNREAD = "ru". But this is not working.
Thoughts? ideas?
const MARK_AS_UNREAD = "ur";
http://persistent.info/archives/2006/03/21/gmail-macros
Go there!
I've updated my macros script to the new version (patch was clean, how nice!).
I've additionally gone through the requests. I can't help the ? not working, it's worked for me on all platforms in the past three months.
For the other concerns, the help info now should position itself towards the top of the screen, I've added a 'v' macro to mark as unread ('q' is taken by focusing on quick contacts). The 'o' expansion now returns focus to the conversation. I believe that addresses all the concerns.
If you want to remove my 'o' command, do a search for '79' and comment out that block (8 lines in the updated file). I will not remove it because enter does the same thing and I actually use the expand all quite often.
Link is still at:
http://gr.ayre.st/~grayrest/greasemonkey/gmail/gmail-macros.user.js
A couple of questions:
1. What's the "9000" after the "Label Selector" text when I hit the 'g' key?
2. I can't seem to get '?' to work to pop-up the Available Key Commands window to pop-up. Is that something that needs to be manually configed?
I will wash cars, shine shoes and clean houses if there is any way you can help get label colors incorporated into Gmail as a standard feature. That is one of THE most useful features that I think would benefit every Gmail user, as the human mind responds to and distinguishes color a lot faster and easier than trying to track down a piece of text in a list of 25, 50 or 100 messages.
Thanks again.
thanks
I'm using gmail to implement a GTD style personal productivity solution similar to that outlined in http://saw.themurdaughs.com/gtd%20with%20gmail.pdf and am making extensive use of saved searches.
My next personal project will be learning js to implement the macros with saved search script, if no one beats me to it.
All macro keys are working beautifully. Mark 'All/None' etc. have made me forget about my mouse.
I made few changes to have the '?' help box show properly in middle of page. Also changed 'V' to 'B' for mark unread, as 'V' is taken by 'View Conversation' script.
Now, can u add a macro key for 'Remove Label' ?
I do it now via (from inbox) : x g y g i
But it will be better if (say) : h
Now, can u add a macro key for 'Remove Label' ?
I do it now via (from inbox) : x g [label] y g i
But it will be better if (say) : h [label]
Try pressing ? two/three times. It sometime happens to me, but pressing ? repeatedly pops the help.
You can download the modified version from below link,
http://coral.anand.googlepages.com/gmail-macros.user.js
I made few changes to have the '?' help box show properly in middle of page. Also changed 'V' to 'B' for mark unread, as 'V' is taken by 'View Conversation' script.
All credits goes to Mihai and Karl. Hope they add further new features to it.
One thing I noted, however, was that when trying to install it, Greasemonkey didn't recognize the script (Firefox prompted me to download it). I believe it is because of the first line, "//~ changes by Anand". I moved that line (and the blank line after it) to after the line that says "// ==/UserScript==" and loaded it up into my browser. Greasemonkey recognized (and installed it) without a problem.
And now I'm a happy GMail Macros user! Thanks very much!! :)
I could not fix the color labels problem. Though I use it to my benefit, for unlabeling a mesg by dropdown list ( it works when colors are not showing :) )
Michael, you do not need to patch anything. Just install latest Firefox and Greasemonkey. Then download the script from this site or from my site as below,
http://coral.anand.googlepages.com/gmail-macros.user.js
I like your label colour script, but there seems to be a bug.
I'm unable to use the "remove label" function from the dropdown menu if the label has a colour assigned to it.
I'm able to use the remove label button though.
labelInput.blur();
The reason being that I use the spacebar to jump up and down the page and after using one of the select actions the input seems to still be trapping the spacebar somehow.
Are there any plans for creating macros for the older oldest newer newest link buttons?
Cheers.
http://johnvey.com/features/gmailapi/
I just wanted to say thankyou so much for the amazing scripts, and also put in a couple requests... This is kinda like my gmail wishlist, and I'm wondering if anyone else is wishing for similar developments:
>Can anything be done at the greasemonkey level to improve browsing/management of the contacts folder? Currently you cannot select contacts via keyboard shortcuts, and once you are inside a contact's details, there is no option to move to the next/previous contact of the found set. As well, any features which could help create some kind of databasing via keywords within Contacts would take gmail to another level.
Thats all... anybody have some thoughts?
Thanks again for phenomenal scripts... my productivity is about to increase exponentially!
nate
Fantastic scripts. Thanks.
Just wondering.
thanks again!
1) "P" (purge) gets in the way of "n"/"p" in conversation view (to move among msgs in conversation)! I changed it to ";"
2) I think this would be revolutionary: ability to take action on the item AT THE CARET without having to "X" it and without interfering with whatever *is* "X"'d...Perhaps +key could accomplish this. Examples:
===Message list view===
+T: trash conversation AT CARET
+E: archive conversation AT CARET
===Conversation view===
+T: trash message AT CARET
+E: archive message AT CARET
Know this would be more of a challenge but you've gotta admit it would be useful!
Thanks again,
Aaron
Good news. Now gmail-macro supports "Remove Label" short-cut.
"B" = Remove Label
"V" = Mark UnRead (as was done my Karl)
The latest script available at:
http://coral.anand.googlepages.com/gmail-macros.user.js
Hope all macro lovers find it more useful now.
Anand
Besides, Conversation Preview Bubbles doesn't seem to work at all.
Any idea how to fix all this?
MK
Mihai had done the job of marking the "Remove label" id but somehow he did not put the codes around. Karl also missed it. It took me some time to figure out how to use the "Label" codes to "UnLabel" logic. The beauty of the script is that it works on color coded labels, even when colors are visible (a feature most of us were requesting for long).
Anand
Ahhh yayzerama for boosted productivity.
How do you handle unselecting all messages w/out using the mouse? Any plans to incorporate something like this in your Greasemonkey script?
Otherwise, great scripts -- improves the usability of Gmail thousand-fold.
Thanks very much for the Gmail labels colors scipt. Very very useful! But I have the same problem as Anand, i.e. when the page auto-refresh, I loose completely the colors, until I do myself refresh the page. Any way around this problem? Thanks
The script HAS the keyboard shortcut for Selecting "All", "None" etc., as M+A to mark all. Checkout the script uploaded by me, link given in earlier mail above. You can see the complete keyboard list in help screen by pressing ?.
Anand
When I hit the tab key, Firefox grabs the command and sends me to the search box, and then the enter key causes an empty search string event.
So, instead of sending, I get prompted to either save the draft or discard. Eeek!
The Conversation Preview Bubbles doesn't work for me either.
Suggestions?
using Gmail Macros with FF 2RC3. All of a sudden "g + label" doesn't work for me, i.e. the label selector shows up, type label, enter, the command doesn't lead me to the desired label.
Any ideas? Anyone else seeing the same?
Thanks a lot!
FRank
g + label doesn't work.
m + (a)ll/(n)one/(r)ead/(u)nread doesn't work
haven't found anything else, but there may be others affected.
Thanks in advance
Thanks in advance
http://borisyim.googlepages.com/gmailmacrosbykarl.user.js
Or better yet: *integrate it.*
http://borisyim.googlepages.com/gmailmacros.user.js
http://borisyim.googlepages.com/GMail_Keyboard.doc
'm' and are still not working though, and it would be nice to have a key equivalent to pressing the 'discard' button (without going back to the conversation list).
Karl has updated his version of the macros to overcome these issues, it can be had here: http://gr.ayre.st/~grayrest/greasemonkey/gmail/gmail-macros.user.js
Also, I've started a Google group for GMail Power Users, to discuss and share tips, scripts, etc. for GMail (it might be a bit easier than searching through all of the comment threads in Mihai's blog ;-) Feel free to sign up here: http://groups-beta.google.com/group/gmail-power-users
http://borisyim.googlepages.com/gmailmacros.user.js
http://borisyim.googlepages.com/GMail_Keyboard.doc
'm' and are still not working though, and it would be nice to have a key equivalent to pressing the 'discard' button (without going back to the conversation list).
1. changed expand/collapse to "Enter"
2. 'm' and "Enter" are still not working ('h' too)
Thanks!
http://persistent.info/archives/2005/12/23/greasemonkey
http://persistent.info/archives/2006/03/21/gmail-macros
Has anybody tried both? Are Boris, mkizer, Karl (and Mihai?) collaborating at all on this?
I've started a Google Group to discuss this (and any other power user tips for GMail) here: http://groups-beta.google.com/group/gmail-power-users
Feel free to join, chat, upload files, etc.
http://coral.anand.googlepages.com/gmail-macros.user.js
All praise to Karl.
Press ? for the list of shortcuts.
Anand
frank
One quirk so far though: I can't get '?' to bring up any kind of help/list of shortcuts.
frank
Try pressing '?' repeatedly. Sometime, help do not pop by press it once.
Anand
Also ? doesn't work. I presume this lists the gmacro functionality in full since I haven't seen it detailed in this post.
Below is the extract from the script help file,
"?" : "Displays this help message"
"T" : "Trash a message or conversation"
"E" : "Archive always/remove from inbox"
"R" : "Mark as Read a message or conversation"
"V" : "Mark as Unread a message or conversation"
"D" : "Discards (Read&Archive) a message or conversation"
"G+label" : "Go to a label (including inbox/star/trash/etc)."
"L+label" : "Applies label to conversation(s)"
"B+label" : "Removes label from conversation(s)"
"M+key" : "Mark (Select) A: all, N: none, R: read, U: Unread, S: starred, T: Unstarred"
"O" : "Expands/Collapses all messages in conversation"
These are above and all of the normal key shortcuts of GMAIL, like "U", "X" etc.
Try disabling any other script and enabling only macro script, and then see if it works ok or not. May be the other scripts are clashing with this script.
HTH
Anand
Thanks in advance
the label color syntax is,
[label name] [color code]
where [color code] begins with '##' and the rgb color number in html (only the first letter)
so the html code for color blue is '0000ff'
take the first letter for each, u get '00f'
the html color code for the green title 'persistent.info' at the top of this web page is '82CC33', but u can not set it as u will have to write '#8C3' which will be a bit different green.
try,
Bookmark ##00f
which will give blue color label "Bookmark"
HTH
Anand
Gogo
mk
GM and FF versions are ok and match with mine.
Get the latest "label color" script from
http://userscripts.org/scripts/show/2433
(in case your's has some problem)
Create a label and name it as
"Bookmark ##00f"
Note the 'space' after 'Bookmark' and two '#'s
Label any mesg as "Bookmark ##00f"
GMail shd display "Bookmark" in blue background color against that mail.
Anand
However, when trying to tweak it, I believe I discovered a bug -- one that absent further modification would probably only cause a slight performance hit, if anything.
In the function getLabelColorInfo, the if statement reads as follows:
if(rawLabelName.indexOf(" #")) { ...
Now, at least here, indexOf returns -1 if the string " #" is not found. That means that the "else" is never evaluated. I was trying to hardwire some colors in the else, and had to change the if statement to the following to get it to work:
if (rawLabelName.indexOf(" #")>0) { ...
mk
Post a Comment