Macros for the new version of Gmail #
As those of you on the new version of Gmail might have noticed, nearly all Greasemonkey scripts that used to work on the old version no longer do. Even though it looks pretty similar, the new Gmail is entirely different from a JavaScript, HTML and CSS perspective, so this isn't surprising. Some of the scripts are no longer necessary. For example, saved searches aren't really needed, since searches now get their own URLs and can be bookmarked.
However, my Macros script is still needed; while the new version of Gmail does have additional keyboard shortcuts, it's still not possible to do everything from the keyboard. I've therefore ported it for the new version of Gmail, to install it, click below.
More specifically, the following keyboard shorcuts have been ported over:
- g: Go to label
- l: Apply label
- b: Remove label
- e: Archive (regardless of view, unlike "y")
- d: Discard (mark as read and archive)
There is also a new keyboard shortcut, which the old script didn't have:
- f: "Focus" the current view (only show unread, starred or inbox messages)
You may remember the script supporting other keyboard shorcuts. Since the new version of Gmail supports additional shortcuts, those have obsoleted. The new ones are:
- shift + i: Mark as read
- shift + u: Mark as unread
- shift + 3: Move to trash (not actually new, but not many people seem to know this one)
- shift + 8 followed by a, n, r, u, s, or t: Select all, none, read, unread, starred, or unstarred
For those of you adventurous enough to look at the script source, you'll notice that it uses a gmonkey
object that is present on the window, which in turn gets you a gmail
object with methods like getNavPaneElement()
and getActiveViewType()
. What this means is that the version of Gmail, in addition to being faster, also has semi-official support for Greasemonkey scripts. I'm pretty sure docs for this API will be out soon, but in the meantime, feel free to look at the script and use a tool like Firebug to investigate the properties of the gmonkey
and gmail
objects and play around.
Update on 11/06/2007: And here are the semi-official docs.
161 Comments
Mason
My account switched yesterday and today you come up with a breand new script... awesome !
Is there any chance you will transfer the Labels Color script as well ? These are really the two most useful scripts ever created for gmail (with the saved searches, but as you said, this is over now).
Thanks for all your time on this project!
I like new even more since IMAP is enabled and I've changed my labels in more "folder" kind of organization.
So, now I have something like dev/perl, dev/osx... and new script is handling this so nice!
Thanks again.
Mark
Any chance of configurable shortcuts and/or integration with mainstream Gmail? :D
It really would be useful to have "New Label" functionality as implemented in an old version of the script (modified by Brent Nef). Any chance of you making a version of your script with that functionality for the new Gmail codebase?
Thanks
Fulop
I also would like to request used configurable shortcuts... for example, I would love to change "delete a message" from "#" to "t" or something else.
Thanks again!
one little quibble... why not bring along all the old shortcuts....
I'm so used to 'Shift+x+u' and 'r' and 't'
the default Gmail ones seem a little random to me... how does shift+i = mark as read?
would also love to get that label colors script
Two things I've realized:
1) The label selector banner never really shows the picked label name. I noticed that the activeLabelAction.func() call was moved out of the setTimeout--this seems to be primarily to prevent the More Actions list from showing up when the mousedown event is simulated, but in doing so, it also eats the banner.update() behavior as well.
2) If the user has enough conversations displayed in the list such that scrolling to the bottom of the list makes the top More Actions list go out of sight, applying a label on a conversation sets the window.location.hash value and the window jumps back up to the top of the message list. Is there a way to specify the More Actions list in the footer?
Keep up the good work.
For all those people asking for the 't' shortcut to be re-instated, I've just looked in the GMail help and the '#' key will move a selected item to the trash.
(e.g. for notifying my private website, analytics etc. whenever i share an item. star an item etc.)
Is something like that available?
I'd also like to add my votes for:
1. Restore the r shortcut for marking messages read since it's more intuitive than Shift+i and aligns with the Shift+8 r combination to select read messages. (It's unfortunate that u is already taken but Shift+u is close).
2. Bring back the help screen. It's a handy guide for learning all the shortcuts (both native and Gmail Macro) as well as quickly remembering infrequently used ones. Thus, a good feature for newbies and veterans alike.
3. Although the t shortcut is intuitive, it's rather dangerous since it's next door to y. So, as much as I like it mnemonically, Shift+3 is safer and I vote no on restoring the t shortcut.
4. Saved searches is definitely worth keeping. As already pointed out, the integration is the benefit. Bookmarks aren't the same.
However, I really just wanted to say thanks for writing this script.
With regards to marking messages as read and unread, how about "r" for read and "R" for unread? I have that in the version I'm running now on the old Gmail (I'm not updated yet) and it's been quite useful.
Also, I'd like the option to use either shift-8 (*) OR "x" to mark things; I could get used to *, but I'm used to "x" with my current macros (modified by Brent Nef, as mentioned above).
P.S. Thank you, thank you, THANK YOU for the update!
1) I also like the "t" for trash.
2) I also think the saved searches were better integrated into the UI.
As deleting email is the Gmail action I use the most, I am strongly in favor of the 't' shortcut, as it is much faster and easier than Shift+3.
Also, when I view the shortcut list, it's really huge and gets cut off at the bottom, with no scrolling. Also, the title is "Keyboard shortcutsnullRAZXF">", which I'm assuming is not the intended title.
If you do make updates, you'll post a comment back here, right? :)
however, the need for t for delete is more than necessary!!!
maybe, you can put it as an option or two versions for those that think that it is dangerous. but there are too many that need that, among who, me...
thanks again
Labels colouring wouuld also be a big help.
THanks again for revolutionizing my gmail life!
on gmail in general - the new backend is very nice. The interface is very responsive - very nice.
I'd like to throw out support for some other features, though, like
1) Ctrl/Shift-Select to select multiple emails, instead of the checkboxes
2) drag-drop emails into labels or mailboxes
3) some kind of tabbed interface so you can work on multiple messages or views at the same time, in different gmail-specific tabs.
This happens most of the time but not always. This is on Firefox 2.0.0.9 on Vista.
I have no other Greasemonkey scripts running. When I disable this script and reload Gmail, the space bar works fine again. And I never have this problem with the older version of Gmail and old scripts.
Anybody else having the same problem?
And please add the help function listing all the shortcuts, so we don't have to consult a web page for them every time!
Thank you for the fast port. I am a big fan and appreciate all your work.
Overall, though, I am very unhappy with the new gmail and the completely messed up keyboard shortcuts. I am going back to the old gmail and old shortcuts until some day when I can be productive with the new one.
I'd vote too for t=trash and r=read. I miss those :(
Save to desktop then right click then open with Firefox
any chance to get this working also with GreaseKit for Safari?
Daniel
I added the help screen back in. Please note the X+key combo doesn't work (as noted).
Here's the script: http://ils.unc.edu/~muela/gmail-macros-bn-edit.user.js
I'm not sure how to upload it to the GMail Power Users group site.
Brent or Mihai, if you see this, can you toss it up on the GMail Power Users group site (if you think it's worthy).
It's enough of an issue that I'm going to disable this script.
@Anonymous: The period-key shortcut to open the More Actions menu is a nice find. Thanks for sharing.
@miles: if you think that would be a useful feature (delete and next). I can throw it together. Let me know. Shouldn't be much different than the function for archive and next. Problem would be that you would need a command for delete and next, as well as delete and previous. Let me know what you think.
PS: Are you a man or a woman? I feel sheepish asking this, but I'm posting info on this script variant elsewhere and I don't know whether to say "he modified" or "she modified". :P
As for the help menu. I just got one. I can't get it to go away on 'escape' for some reason, but then again I haven't tried that hard *g*. If anyone has any pointers, lemme know. For now, if you look at the help menu on the right side, it list a hide option by pressing Shift-H ('H'). there shouldn't really be two different menus mostly because both ? and h call the same function. I'll remove one of them though and see if that helps.
Regarding the help menu, Shift-H does work, though I can't see the top portion of the box. Somehow, and I have no idea what the method was, Brent made his old one scrollable. You'll have to ask him what he did. I'm guessing it's something to do with CSS.
Meanwhile, could you make it so clicking outside the box or hitting Esc closes it? That way it won't be such a shock for people switching form other versions, and the usability is a bit easier. Brent's original script should be able to help with that, too. There are several archived versions of the old Macros scripts in the Group's files section.
i hit 'l' to label 2 marked conversations, then begin to type 'software' to label them...however, the 's' ends up starring the conversation i'm pointing at, and eventually i end up writing a reply to the email...not what i wanted at all. through all this, the 'apply label' box floats mid-screen, and i have to refresh the page to make it go away.
has gmail been further modified since this script was updated?
> i hit 'l' to label 2 marked conversations, then begin to type 'software' to label them...
I hit l, and then start typing "software" (or "stuff" in my case) and it works fine. The dialog shows "software", and I don't get a reply window or archive window, etc. Strange, don't know why you're getting this. Can you check the javascript console (Tools, Error Console) and see if there are any javascript errors from the script? (Helps to click on the Errors tab to hide all the warnings). May be interference from another script or something like that.
just now, tried to label something 'personal', and ended up archiving them (because of the 'e' keypress, i think). the label box didn't register any keypresses at all, and stayed there once the conversations were archived.
So please, pretty please could you make them work again and never abandon them? Google will only provide for so long the older version where they work :(
I'm using it again.
Has anyone else noticed this?
Thanks.
> @Rob: Using g+i shouldn't be necessary any more; Gmail's message list can be refreshed with the built-in 'u' shortcut.
That's good to know. I used to use g+i to refresh the inbox also, I'll just start using u from now on. Thanks!
By the way, GreenPlastik, Brent's been updating his version of Macros, as I'm sure you know from the Gmail Power Users group. It looks good. Google made a DHTML prompt for the new label action, though, so it's not as convenient as before. The return key no longer hits OK for you; you have to enter the label, then tab to OK and hit return. Ho hum...
I also vote for 't' for trash,
'N' for new label, 'L' for un-lable, and pretty much most of the original short cuts. I think the key is to make them as easy as possible and as efficient as possible.
Desperately need colored labels as well.
I know you will continue to make this the best product ever.
http://userscripts.org/scripts/show/13250
I've only just installed it, but it seems to work so far.
as i just commented on the colour labels userscript page:
"there seems to be a conflict with the new version of GMail Macros. attempting to use the macros to label something with a colour suffix doesn't work.
for example, attempting to label something 'MyLabel #000000' results in an error/alert box claiming that GMail cannot find the node 'MyLabel' (it does not seem to look for the label+suffix, just the label)."
not sure which script would need to be modified to make them compatible.
It was one of the best shortcuts.
More over, in France, we don't have the same keys for #. I must use Alt GR + 3 :-(
tsk tsk! u should use shift+g
In order to install the gmail macros, you need to install Greasemonkey, restart Firefox, then click the 'Install Gmail Macros' link. If you do not have Greasemonkey installed, you will only get a page showing the Javascript.
There's just one thing I think it's missing. GMail has a way to go to all unread messages (l:unread) acting as if there is an 'unread' label. But hitting l and typing 'unread' does not access this functionality. Do you think you could add it? Either accept 'unread' as a built-in label, or have a g+u to go there. That would really make it _flawless_
Thank you =)
Please bring back the "h".
It doesn't have the Macros specific changes though, but you're probably using Macros because you're using the extra keys, so it won't be difficult to remember.
g/l/b for label actions.
archivE, Discard, Focus
Description: open gmail, navigate to a label using macros, navigate back to Inbox. Presto! Nothing works for scrolling the screen: space bar, page down, arrows.
Nothing! Annoying like hell.
The only way I know to fix this is to press "/" to get to the search field and then press ESC. Then I can scroll.
Running Firefox 2.0.0.11 on Vista. I uninstalled ALL other add-ons and Greasemonkey scripts for testing this.
I've noticed a lot of little problems like this with Firefox. I haven't been able to figure out what it is, but I've also seen these on google reader and also on any webpage opened by google reader.
What used to happen is that I'd press "V" in reader to view a webpage, and it'd open in a new tab in the foreground. However, at this point I would not be able to use any keyboard commands (up, down, pageup, spacebar, /) for anything. I could hit Control+F for the find bar and then escape, and then everything would work. I could also click once on the webpage and then it would work.
This was never related to textboxes or inputs capturing the keyboard, it was all due to some firefox focus bug. A while ago (few releases back) it used to do the same thing, but when I was looking at the foreground tab and pressing up or down, it would actually move the original page without my knowledge (all keyboard commands were sent to the wrong tab). It hasn't done that in a while.
My thought is that all these focus bugs are firefox related, but I could be wrong. Recently gmail has been giving me more trouble when it randomly decides to not respond to keyboard commands as you describe. Often I'll either go to another tab and return, or I'll archive "A" an email, and then the whole thing is unresponsive. I'll have to click on the page to get any keyboard commands working again. Frustrating.
I am sure that this is the problem with Mihai's script and not with Firefox.
Here is how I fixed it today: I uninstalled the script and installed "Modified Gmail Macros v.2.0" from the "Gmail Powerusers" Google group. I am not having the described scrolling problems with that script.
Normally, I am trying to stay with the original Mihai's scripts, figuring they would be faster and have fewer bugs... But there was no response from Mihai to these scrolling problems.
Conjecture: the extended macros will appear soon in the official version of Gmail. Indeed, the colored labels are already there...
How about Attachments Icons, too?
It doesn't seem to recognize labels with forward slashes which is how Gmail works now with IMAP folders.
I'm using "Better Gmail 2" extension on Windows Firefox 2. This does seem to work with "Better Gmail" original, using the "Older Version" of Gmail.
Thanks in advance for any helpful comments.
By the way does this script work with hosted Google Apps mail?
Are you going to update the fixed font toggle script for the new Gmail?
Since this doesn't appear to be happening to too many other people, it's probably something on my machine. I'm using WinXP Tablet Edition on my Toshiba Tecra M7 tablet PC. I'm also using UltraMon & Maxi-Vista to support three monitors. I have many add-ons enabled; here are the relevant ones: Better Gmail2, FFClickOnce, FirefoxView, Firebug, GeckoTIP, Google Browser Sync, Google Gears, Grab and Drag, GreaseMonkey (obviously), IE Tab, Mouse Gestures, MR Tech Local Install, Plain Text to Link, Tab Scope, Skype, Web Developer (and a few others I doubt are related).
If anyone else is having this problem, can you post your PC setup and which of these extensions you are using? It's really frustrating and hopefully someone can help me figure out what's wrong.
Thanks,
Bob
So using l to Apply Label works for some labels and not others if you don't first select the message(s) to label. It works ALL the time if you DO select the message(s) first. Hopefully, this will help someone else who was as confused and frustrated as I was.
Bob
Turns out the problem I was having is still an issue if you are viewing an email (i.e. not in the conversation thread view).
For example, if I'm viewing a message and want to add a label that starts with an "S", I hit "L" and the Apply Label window appears as expected. However, if I type "S", instead of having my first label that starts with an "S" appear, the message gets starred.
Is anyone else having this problem or know of any way around it?
Thanks,
Bob
What gives?
Any thoughts/advice?
Thanks.
t : trash
on line 24 paste this one line:
var DELETE_ACTION = "10";
then on line 85, paste the following code:
// t: delete (move to trash) action
84: function() {
var deleteButton = getFirstVisibleNode(
evalXPath(".//button[@act='" + DELETE_ACTION + "']", getDoc().body));
if (deleteButton) {
simulateClick(deleteButton, "click");
} else {
clickMoreActionsMenuItem("Delete", ARCHIVE_ACTION);
}
},
thats it, refresh your GMail wnidow/tab, and start hitting t to move a button to Trash.
Basically a GTD method.
In any case, thanks for your work on this!
The need for a saved searches box in addition to the labels box is so apparent. I use saved searches all the time(like "is:unread in:inbox" and other useful saved searches that it is annoying to have to memorize) Using bookmarks for saved searches sucks really bad. :( I'm surprised that google hasn't already implemented this feature.
Now that you're all buttered up =) I'd like to make a request (if this is even possible):
Send an email + archive the thread in one step. Instead of tab, enter, e to send then archive a thread, could you cut that into one step? (I'm not sure if this is feasible because of the text box limitations.)
I hope you like my idea and there is an easy way to implement it. Thanks!
Will
cheers,
cheers
This may be the "fix" or Mihai may have just fixed the bug in the latest version.
Hope this helps someone.
My favourite is 'Quick links'; just another incarnation of 'Saved Searches'; something have been asking for so many months here!
Go enjoy.
It's pretty indeterministic, and I cannot find any reliable way to reproduce it :(
The Better Gmail2 macros is nice, but it doesn't seem to have the 'label' feature, where you hit 'l' and then can type the name of archive you want the archived message to go to.
Also, when i try to type in this comment - i'm using firefox 3, the below 'captch' shows up as empty/blank, so I have to use safari to write this.
I suggest using 'G' instead for 'Goto label'
I absolutely love this script! The one catch I find is with the automatic applying of a label when a match is found.
Is there a way to make it require that I hit return to apply a label?
Here's the problem:
I have a label called "house". So I hit "l" and start typing "house". Super Cool!
The label is applied automatically when I type "ho" because "ho" is a unique match for "house" out of all my labels at that point.
But my fingers keep going because I can't keep all the unique match character limits straight in my head. "ho" for "house", "gar" for "garden". And it changes when I add new labels.
Then a bunch of weird stuff happens because all of the remaining characters in "house" those being "use" are treated as keyboard shortcuts.
All of a sudden my label is applied and gmail is doing all sorts of crazy stuff.
u = nothing, but I swear I hear gmail ululating
s = star
e = archive
What I really want is:
1) for gmail to stay calm. No suprise ululation.
2) Let my fingers keep going and let me decide that I have the label I want.
3) let me hit return and then have the label applied.
This script is a stroke of brilliance. Thanks for creating it!
Paul
Is this script just broken for now?
Instead, you have to hit "Return" in order to have the label applied.
A description of the change and a copy of the script with the change are available here.
I find that the Gmail labs feature "Right Side Labels breaks this script. If you turn that one labs feature off this script starts working again.
Hope that helps.
Paul
Also, I figured out my problem; if I switch profiles in Firefox, it breaks gmail macros. I have to clear the cache and reload gmail and then it works. Totally strange, but there you go. So I finally have macros working again.
Thanks!
Anyway this is the correct link to the script.
For what it's worth, the change to update the script was very simple.
Line 350 changes from
if (event.keyCode == 13 || selectedLabels.length == 1) {
to
if (event.keyCode == 13){
I did, however, run into problems combining his script with GTDinbox. GTDinbox redoes the label box and labels that macros reads are split erroneously by forward slashes (IE macros reads "Waiting On" instead of "S/Waiting On"). I'm looking into a solution for that.
How about something for sorting gmail messages alphabetically by subject?...
b.
How about something for searching with an asterisk * wildcard ?...
c.
How about something for searching by the initial characters in the subject line or in the author from line?...
I'd love a version of this that would either override Google's own labeling, but as long as I can still have the d command for mark as read & archive, I'll live. But I cannot live without that!
Please update your script!
I turned on the Go to label feature in Gmail Labs, but... it just isn't the same.
so yeah this is cool but I tried invoking some of the commands in my gmail account and they don't work. It draws a blank. I have the script installed and I have it enabled. Is there something else I may be missing?
So, I customized (remaked) Gmail Macros and released at Gmail Macros for Greasemonkey.
Of course, "Go to label" function is active. And, "l (small L)" acts as "Apply or Remove label".
Post a Comment