Greasemonkey Script Updates #

There have been some reports that my Gmail Macros Greasemonkey script no longer works. I started to look into fixing this, and figured that while I was at it, I should incorporate the improvements that others have made to the script back into the original one. Both posts about it have a growing number of comments, including patched versions with various tweaks. Additionally, there is a Google Group dedicated to Gmail power users that seems to have made even more changes. The script has been updated and now contains the following additional commands:

  • b: Remove label
  • z: Mark unread
  • o: Expand/collapse all messages in a conversation
  • shift-x + a/n/r/u/s/t: Select all/none/read/unread/starred/unstarred
  • h: Show help (reference for built-in and the script's keyboard shortcuts)

Thanks go to Karl, Anand and Michael (?) for these improvements. If I have missed anyone, please let me know.

On a related note, my Google Reader/Gmail integration script has spawned two variants, one by Rob Radez and another by Winston. They went for slightly deeper integrations, if you like the original you may like these too.

28 Comments

Any chance of updating the gmail preview and label colorizer?

I love the color labels, but I am having a heck of a time trying to get the names to appear without the color tag on them in the Labels section on the left. Also, the formatting seems to disappear at times (running just your code).

EXCELLENT work on them all!
Am I the only one that HATES replacing the 'o'pen shortcut? I use dvorak, and i like having j, k, and o all on the left hand to go up and down and opening. My right hand stays on the mouse. I edit every "fixed" version of gmail macros to remove that shortcut.

Anyway, thanks for your awesome GM scripts, they've become irreplaceable to me very quickly.
I finished the script to hide the color tags in the labels section. It can be found here.
That or here...

http://ustice.blogspot.com/2006/11/greasemonkey-script.html

Darn stripping out HTML tags. Oh well, such is the price of security.
I use dvorak too, loved 'o' the way that google had it originally used. I fixed it in my script, plus I made it pretty easy to reconfigure all of the keys. You just need to find the javascript keycode (from anywhere on the intarwebs) and replace it for the function you want. Shifted keys just need an 's' following the keycode. You can get it from here:

http://groups-beta.google.com/group/gmail-power-users/web/gmailmacrosBN.user.js
For that matter it shouldn't be too difficult to create a preferences pop-up which can be accessed from the Greasemonkey icon (with a right-click).
This is the BEST thing to happen to e-mail since Gmail. This functionality really extends Gmail to the power user level and I've converted back from even using Mozilla Thunderbird.
Has anyone figured out how to make "Gmail scripts" work with the GTD plug in?
Thanks for the update, the script runs great (just have to burn the new keys into my brain...or edit the script ;-)
I've created a printable cheat sheet available here: http://docs.google.com/View?docid=dn8w3vq_2gxd5hk
Also, check out the power users group mentioned above for great discussion and mods to this script.
It would be great if to compliment the ! key marking things as spam, if it was executed in the spam "label" to mark things as not spam. It's the only thing that I have to reach to the mouse to do right now, and I do get a pretty good number of non-spam messages marked as spam, unfortunately (at least 20 a day).
-X doesn't seem to be working for me. Anyone else having this problem?
Hi all,

I have posted a simple patch for GMail macros script, that allows you to GOTO/'Apply Label' even if the "Labels" table on left is in closed state. I have posted it here (dated Nov 19, 2006):

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

But, even though I idented the whole text properly, it all got messed up; perhaps that's not a place to post code or big notes of 'Thank You'. Thankfully, I had surrounded the code peices with <code></code> tags, so it is worthwhile for anybody who takes a little pain.

Anyway, I am posting just the patch part here:

Note to non-JS/novice guys: <code> and </code> tag are just delimiters, do not add them to your script; add just what is between them.

Declare a global variable (preferably just before "function beginLabelAction()"):

<code>
var closeLabels = false;
</code>

Now, add the following 4 lines at the beginning of "function beginLabelAction()":

<code>
if (document.getElementById("nt_0").nextSibling == null){
closeLabels = true;
simulateClick(document.getElementById("nt_0"), "click");
}
</code>

Now, at the end of "function endLabelAction()", add the following 4 lines:

<code>
if (closeLabels == true) {
closeLabels = false;
simulateClick(document.getElementById("nt_0"), "click");
}
</code>

Hope you like this small feature.

Best regards,
Gurjeet.
Here's a challenge: there's a Gmail gadget for Google Personal Home Page. I use it to check my inbox when I'm too lazy to open a Gmail tab.
You can click on messages there, which will open them in a new Gmail window (tab). But how about opening them in "preview" mode, just like your "Gmail conversation Preview" GM script, straight from the home page?
I loved this feature on 1.5. Can you tell me if it works for Firefox 2.0?
Gurjeet, thanks for the patch, I've incorporated it into the latest version of the script.

Brian, the latest version of this script should work in Firefox 2.0.
Any chance of a Greasemonkey script to add a little "mark read/unread" button next to the checkbox for each mail item? That would be really handy.
Unfortunately I cannot label, if the label contains ":" Can someone please help me?
This comment has been removed by the author.
I was annoyed by the fact that the banner dealing with labels didn't show you what labels your input was matching. So I modified the script to show potential matches.

updateLabelAction() {
//...
if (labelPrefix.length == 0) {
banner.matches(selectedLabels); // added this line
return;
}
//...
banner.matches(selectedLabels);
}

getNodeSet() {
//...
boxNode.appendChild(messageNode);

// added the following
var matchesNode = newNode("div");
with (matchesNode.style) {
fontSize = "16px";
fontFamily = "Lucida Grande, Trebuchet MS, sans-serif";
margin = "0 10px 10px 0";
}
boxNode.appendChild(matchesNode);
// added to here

var taglineNode = newNode("div");
//...
}

//added below Banner.prototype.update

Banner.prototype.matches = function(matchesArray) {
if (matchesArray.length) {
this.backgroundNode.firstChild.nextSibling.style.display =
this.foregroundNode.firstChild.nextSibling.style.display = "inline";
} else {
this.backgroundNode.firstChild.nextSibling.style.display =
this.foregroundNode.firstChild.nextSibling.style.display = "none";
}
var msg = this.backgroundNode.firstChild.innerHTML;
var html = '<span style="color:lightgrey">';
for (ii in matchesArray) {
if (ii == 0) {
html += matchesArray[ii].substring(msg.length);
}
else {
html += "<br/>" + matchesArray[ii];
}
}
html += "</span>"
this.backgroundNode.firstChild.nextSibling.innerHTML =
this.foregroundNode.firstChild.nextSibling.innerHTML = html;
August, could you explain what you did with that patch? Do I add it to the end of the script or do I have to add individual lines here and there?
has anyone seen a script to add "check mail now" button to the main page of gmail to check other pop3 accounts? It's so annoying to have to go to settings->accounts->check mail now...
For my patch the first few parts have to be added to the respective functions. But the last part should go at the bottom of the script.

You know what, I'll make my modified script available to download.
I wanted more free-form labeling, so I could use non-predetermined labels. So I changed the updateLabelAction function:

function updateLabelAction(event) {
// We've already dispatched the action, the user is just typing away
if (dispatchedActionTimeout) {
return;
}

selectedLabels = new Array();

// We need to skip the label shortcut that got us here
var labelPrefix = labelInput.value.substring(1).toLowerCase();

banner.update(labelPrefix);

if (labelPrefix.length == 0) {
return;
}

for (var i=0; i < labels.length; i++) {
if (labels[i].toLowerCase().indexOf(labelPrefix) == 0) {
selectedLabels.push(labels[i]);
}
}

// ADDED:: show the suggestions on the line below
banner.update(labelPrefix + "<br/>\n" + selectedLabels.join(' '));

if (event.keyCode == 13) {
// CHANGED: invoke the actual label typed (TODO: tab-completion)

activeLabelAction(labelPrefix);
dispatchedActionTimeout = window.setTimeout(
function () {
endLabelAction();
}, 400);
}
I love GreaseMonkey very much, One of the best gift for developers.

Thanks

Myspace Proxy
Afrid.com
FYI, this script isn't working anymore with the new version of Gmail that just came out.
Any updates when the macros will work with the new, faster gmail?

Thanks!
Nooooooo! My firefox updated itself to 2.0.0.9 and now none of your awesome scripts are working! Please fix them... I was just starting to love them.
Hehe, oops... it's the new gmail that's the problem, not the new firefox. ;) Your scripts are seriously great. Are you going to update them?

Post a Comment