Skip to content

Instantly share code, notes, and snippets.

@lfaraone
Created February 19, 2014 19:22
Show Gist options
  • Save lfaraone/9099554 to your computer and use it in GitHub Desktop.
Save lfaraone/9099554 to your computer and use it in GitHub Desktop.
Gmail message-ID / permalink finder
javascript:(function () {
gmonkey.load("1.0", function (gmail) {
if (gmail.getActiveViewType() !== "cv") {
alert("You need to be in a conversation view for this to work.");
return;
}
var xhr = new XMLHttpRequest();
var uri = "?ui=2&ik=" + GLOBALS[9] + "&view=om&th=" + document.location.hash.split("/").reverse()[0];
xhr.onreadystatechange = function () {
if ( xhr.readyState == 4 && xhr.status == 200 ) {
var lines = xhr.responseText.split("\n");
for ( var i = 0; i < lines.length; i++ ) {
if ( lines[i].indexOf("Message-ID:") == 0 ) {
msgid = lines[i].split(' ')[1];
document.location.hash = "#search/rfc822msgid:" + msgid;
break;
}
}
}
};
xhr.open("GET", uri);
xhr.send();
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment