// ==UserScript==
// @name Gmail - One Click Conversations
// @namespace http://www.jeffreykeen.com
// @description Allows you to view recent conversations with someone in just one click. Also adds rollover popup menu (ala built in quick contacts) to all messages.
// @include http://mail.gmail.com/*
// @include https://mail.gmail.com/*
// @include http://mail.google.com/*
// @include https://mail.google.com/*
// ==/UserScript==
/*
Author: Jeff Keen - http://www.jeffreykeen.com
Features:
+ Adds icon just to the left of sender name in list view and in message view
+ Rolling over icon pops up menu, as found via the "quick contacts" panel
+ Clicking on icon takes you to the recent conversations with that user
+ Adds "Recent Conversations" item to pull down menu in the message view.
Requirements:
+ GMail view must be set to "standard with chat".
Testing:
+ Works with Firefox 2.0 for Mac or PC with Greasemonkey
+ Definitely doesn't work with Cream Monkey for Safari.
Version History:
1.0 - 12.29.2006 - Initial Release
1.1.0 - 12.30.2006 - One bug fix turned into major restructuring.
1.1.1 - 01.17.2007 - Checks if chat is enabled to prevent icons from showing up without any functionality.
1.1.2 - 04.06.2007 - I changed the name from Quicker Contacts to One Click Conversations, a name that better describes what the main use of this script is.
1.1.3 - 04.19.2007 - The script now alerts you if chat isn't enabled, and provides a link to enable it.
*/
const CLOCK_IMAGE = "data:image/gif;base64,R0lGODlhCgAKAKIAADMzM//M/7CwsGZmZv///8fHxwAAAAAAACH5BAEHAAEALAAAAAAKAAoAAAMp" +
"GDo8+kOUItwqJJPioh5ZNWAEmHHjdzKCRrRVAJAn8AASZT/BAACWQAIAOw==";
const PERSON_IMAGE = "data:image/gif;base64,R0lGODlhCgAKALMAADMzM//M/9LS0mZmZrm5ue7u7v///+rq6t3d3QAAAAAAAAAAAAAAAAAAAAAA" +
"AAAAACH5BAEHAAEALAAAAAAKAAoAAAQpMMhBh7xDGCMsPtvhTaAhXkF2HB2aEsQ4ITQyDkWNFB5e" +
"/D8PYEgcBiIAOw==";
function evaluateXPath(aNode, aExpr) {
var xpe = new XPathEvaluator();
var nsResolver = xpe.createNSResolver(aNode.ownerDocument == null ? aNode.documentElement : Node.ownerDocument.documentElement);
var result = xpe.evaluate(aExpr, aNode, nsResolver, 0, null);
var found = [];
var res;
while (res = result.iterateNext()) {
found.push(res);
}
return found;
}
function chatEnabled() {
var chat=document.getElementById("nvq");
if (chat) {
return true;
}
else {
return false;
}
}
function listenToList(bool) {
/* adds/removes event listener to the list view */
var list=document.getElementById("co");
if (list) {
if (bool==true) {
list.addEventListener("DOMNodeInserted", modListView, false);
}
if (bool==false) {
list.removeEventListener("DOMNodeInserted", modListView, false);
}
}
}
function listenToMessages(bool) {
/* adds/removes event listener to the message view */
var msgs=document.getElementById("msgs");
if (msgs) {
if (bool==true) {
msgs.addEventListener("DOMNodeInserted", modMessageView, false);
}
if (bool==false) {
msgs.removeEventListener("DOMNodeInserted", modMessageView, false);
}
}
}
function IsMessageView() {
var query="//div[@id='fic']";
var result=evaluateXPath(unsafeWindow.document,query);
return (result.length > 0 ? true : false);
}
function IsListView() {
var query="//div[@id='tbd']";
var result=evaluateXPath(unsafeWindow.document,query);
return (result.length > 0 ? true : false);
}
function OKToModList() {
if (IsListView() == true) {
/* make sure we're haven't already made our mod */
var query="//div[@id='tbd']//img[contains(@id,'_pro_')]";
var icons=evaluateXPath(unsafeWindow.document, query);
return (icons.length > 0 ? false : true);
}
else {
return false;
}
}
function modListView() {
if (OKToModList() == true) {
/* Remove event listener to prevent unnecessary recursion */
listenToList(false);
/* get our address, so we don't create quick link to ourself in the case of conversations */
var myAddressNode=evaluateXPath(unsafeWindow.document, "//td[@class='trb']/b");
if (myAddressNode.length > 0 ) {
var myAddress=myAddressNode[0].innerHTML;
}
/* find all message objects */
var msgs = evaluateXPath(unsafeWindow.document, "//tr[contains(@id, 'w_')]");
for (i=0;i
' + icon + unescape (messageText) + 'Enable Gmail Chat |