Sunday, May 6, 2007

Multiple HTML Reply Signatures for Gmail

I've upgraded the HTML Reply Signatures for Gmail script. The Multiple HTML Reply Signatures for Gmail Greasemonkey script does the following:

1. When the user composes or replies to a message, an HTML signature is inserted in the Gmail editor by default.
HTML Signature injecting in Gmail Reply
2. At any time before pressing 'Send', the user can select another HTML signature from the drop down list in the left navigation menu of Gmail.
Select different Gmail Signatures for Replies or Composes

Multiple HTML Reply Signatures for Gmail Demo


This is a demo Gmail content window that demonstrates the plug-in behavior of the Multiple HTML Reply Signatures for Gmail script. Use the drop-down list on the left to toggle between different signatures.


I've also addressed issues regarding the HTML signature placement. This script places the signature at the end of the reply, not at the end of the thread. I've noticed that the subject of HTML signature placement is a hotly debated topic. However, my reasons for placing the HTML signature at the end of the reply are as follows:

1. I find that I rarely, if ever, scroll through quotes from previous emails in a thread unless I need to refresh my memory; therefore, I find that I am less likely to see a signature that is at the bottom of the thread.
2. After several replies back and forth, signatures will begin to accumulate at the bottom of the thread. Because of reason #1, none of these signatures will be seen anyway, unless I need to reference an earlier part of the conversation. If I do scroll to the bottom, I'll see multiple instances of my signature and that of the person I've been collaborating with.
3. Keeping the entire message content at the top of a reply helps identify the boundary of where one message ends and another begins. Placing the signature at the end of the reply clearly identifies where the end of the reply is and where the previous email begins.

However, I realize that there are people who will disagree and insist that the HTML signature be placed at the bottom of the thread. If you want to move the HTML signature to the end, by all means, go for it. It is actually easier to code the script so that signatures are placed at the end. So, if you need help with this modification, let me know.

It is also worth noting that the dropdown list can be configured to plug in different signatures for replies than for initial composes; however, the drop down list values will be the same. What this means is this: I can configure a "Personal Signature" for replies and a "Personal Signature" for initial composes. Likewise, I can configure a "Work Signature" for initial composes and a "Work Signature" for replies. I can also set them to be the same. However, in any case, the dropdown list values will always be the same.

Finally, the script can be configured to insert no HTML signature by default. As long as the htmlsignature and/or htmlreplysig variable has a beginning span tag with an id="image_sig" and a closing span tag, anything, including whitespace, can be placed in the innerHTML. Once an HTML signature is selected from the dropdown list, only signatures from that list can be selected. Therefore, it is important to ensure that the default HTML signature is also in the dropdown list. It is for this reason that the fourth option in the dropdown list is configured as "No Signature", which sets the innerHTML to whitespace. Therefore, if a user decides not to use an HTML signature after selecting one, it can be removed by selecting this option.

In order to use this script, you must have Mozilla Firefox 1.5 or higher and the Greasemonkey firefox extension installed. If you've already installed Firefox and Greasemonkey, you can go ahead and install the Multiple HTML Reply Signatures for Gmail script.

UPDATE: The script is now available as a Firefox Extension!


Ilan said...

Hi There,

I have installed the plugin and I can assign the multiple signatures but where do I configure the signature itself?

James Mortensen said...

Click "Tools -> Greasemonkey -> Manage User Scripts"

In the "Manage User Scripts" window, select "HTML Multiple Reply Signatures for Gmail"

In the bottom left corner of the window, select "Edit". This will open the script in an editor, if Greasemonkey has already been configured with an editor. If a window opens asking you for the location of a text editor, simply type "NOTEPAD.EXE".

To edit your signatures, simply edit the commented lines in the script:

//define your different signatures for initial composes here --
var htmlsig0='<p>--<br><img src= border=0></p>';
var htmlsig1='<p>--<br><h2>James Mortensen</h2><h2></h2></p>';
var htmlsig2='<p>--<br><p>James Mortensen<br></p></p>';
var htmlsig3='';

//define your different signatures for reply emails here --
var htmlreplysig0=htmlsig0;
var htmlreplysig1='<p>--<br><p>James</p></p>';
var htmlreplysig2='<p>--<br><p>James Mortensen<br></p></p>';
var htmlreplysig3='';

Edit the HTML within the quotes with the desired signature for each option for an initial email compose and for replies. You do have to know some basic HTML and JavaScript, but if you're still having trouble I would be more than happy to help.

In the future, I'm hoping to compile the Greasemonkey script into a Firefox Extension and create a nice user interface instead.

Jes said...

Hi James,

First and foremost I must say that this is a very useful script. I was looking for this kinda thing for ages. Soo thank u very much:)

But I am having some trouble with editing the signature. I found that when I use of some html tags such as 'font' and 'HREF' the script stops working....

Any solution??? Because I need to change the colour of the fonts and I need to insert an URL (clickable) in the signature....


James Mortensen said...

Hi Jes,

Thank you for your comment. I'm glad to hear that the efforts of myself and the other individuals who developed the first Gmail Signatures script are solving a need for you.

To answer your question, I tried using the 'font' and 'a' HTML tags and was only successful if I omitted quotations from the size and href attributes. Here is a working example:

Code sample:

var htmlsig3='<p>--<br><font color=#3fc543 size=15>Large</font><a href=>Link to Google</a></p>';

Please note that the script will not work for font size="15" but only font size=15 without the quotes. The same is true for the href attribute. You can use this attribute, but you must not use quotes.

Please email me if you are still having problems, and I would be glad to help. In your email, please include the definitions for the htmlsig and htmlreplysig variables.

Jes said...

Hi James,

Thanks for helping me out. Your solution worked like a charm. Thanks again....

All the best with your work and hope to see the firefox extension really soon.


James Mortensen said...

I'm glad to hear you were successful in getting the script to work.

The Firefox Extension development is moving along at a moderate pace. I compiled the script using the Greasemonkey compiler.

It didn't work right out of the box. I had to correct a bug in the auto-generated code. However, after fixing the bug, the signatures appeared flawlessly in the Gmail editor.

So now I've been working on creating a XUL front-end so that users can edit signatures without having to open the JavaScript file.

The user interface is almost complete. The next challenge will be integrating the textbox fields in the user interface with the variables in the userScript, as well as saving this data to the file system.

Anna said...

Hi :)

This is beautiful! Really exactly what I need! But I'm afraid I could use some help, please?

No matter what I try, the drop-down menu to choose signatures does not appear in Gmail.

I installed the extension ( I went and learned just enough HTML to make a variety of decent signatures, (I'm a designer not a programmer ;)

I tried:
1) disabling the automatic signature in my Gmail settings in case that was causing a problem, (probably a dumb idea and it didn't work)
2) uninstalling the extension, and installing Grease Monkey and the SCRIPT. This is totally out of my league as I don't know how to edit the script properly. I thought I'd just go and see whether a drop-down appeared, but it didn't...
3) installing the extension on my laptop. still no dropdown...

I'm on two slightly different macs...
OSX 10.5.2, Firefox and
OSX 10.4.11, Firefox

If James (or anyone?) can help me out with this I'd appreciate it tremendously...many kind thanks.

Larry said...

James, I also don't see a dropdown box on Google for my sigs. Same issue as Anna, above. I suspect a newer version of GMail messed up your add-in?? Any help would be appreciated.

Thank you!

James Mortensen said...

Hi Larry,

Currently, the Firefox extension and Greasemonkey script only work in Gmail version 1. You can switch to Gmail version 1 by clicking on the link for the "Older Version" in the top right corner of the Gmail interface.

I'm currently working on an update for version 2, but at this time it's still very spotty.


JeromeDane said...

You may want to check out the following add-on for Firefox that lets you easily manage multiple rich HTML signatures for each address you have set up in Gmail:

James Mortensen said...

Thanks Jerome. I've seen Blank Canvas's Firefox extension and It's great! Some co-workers at my company use it with our corporate Gmail.

I'm working on a Gmail 2/Firefox 3 compatible version of Multiple HTML Reply Signatures for Gmail. Perhaps I should include this feature as well.

There are many other examples of great Gamil Signature Greasemonkey scripts and Firefox extensions. All offer different combinations of features and functionality, and I encourage everyone to choose the one that works best for them.


Anna said...

Great and Useful Article.

Online Java Training

Java Online Training India

Java Online Course

Java EE course

Java EE training

Best Recommended books for Spring framework

Java Interview Questions

Java Course in Chennai

Java Online Training India

Sankar lp said...

I have read your blog its very attractive and impressive. I like it your blog.

Email Marketing India Email Marketing Services India