Revision: 19610
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 27, 2009 08:45 by roryok
Initial Code
javascript:(function(){function%20f(r){var%20t=r.getElementsByTagName("span");var%20i;for(i=0;i<t.length;i++){if(t[i].hasAttribute("email")){return%20t[i].innerHTML}}return%20""}function%20ds(a,b){a=a[0].toLowerCase();b=b[0].toLowerCase();if(a<b)return%20-1;if(a>b)return%201;return%200}function%20sl(m){var%20l=Array.prototype.slice.call(m.getElementsByTagName("tr"),0);if(!l.length)return;var%20b=l[0].parentNode;var%20s=[];for(var%20i=0;i<l.length;i++){s[i]=[f(l[i]),l[i]]}s=s.sort(ds);for(i=0;i<s.length;i++){b.appendChild(s[i][1])}}var%20m=document.getElementById('canvas_frame').contentWindow.document.getElementById(":on");if(m)sl(m)})() // Expanded Script javascript:(function(){ function findFrom(r) { var span = r.getElementsByTagName("span"); var i; for (i = 0; i < span.length; i++) { if (span[i].hasAttribute("email")) { return span[i].innerHTML; } } return ""; } function doSort(a,b) { a = a[0].toLowerCase(); b = b[0].toLowerCase(); if(a<b) return -1; if(a>b) return 1; return 0; } function sortList(m) { var list = Array.prototype.slice.call(m.getElementsByTagName("tr"), 0); if(!list.length) return; var tbody = list[0].parentNode; var sortList = []; for(var i=0; i<list.length; i++) { sortList[i] = [findFrom(list[i]),list[i]]; } sortList = sortList.sort(doSort); for(i=0; i<sortList.length; i++) { tbody.appendChild(sortList[i][1]); } } var messages = document.getElementById('canvas_frame').contentWindow.document.getElementById(":on"); if(messages) sortList(messages); })()
Initial URL
Initial Description
This is based on the [Sort Gmail Messages By Bookmarklet](http://snipplr.com/view/10432/sort-gmail-messages-by-subject/ "Sort Gmail Messages By Bookmarklet - http://snipplr.com/view/10432/sort-gmail-messages-by-subject/") snippet. Drag this into your Bookmarks: [SortGmailBySender](javascript:(function(){function%20f(r){var%20t=r.getElementsByTagName("span");var%20i;for(i=0;i<t.length;i++){if(t[i].hasAttribute("email")){return%20t[i].innerHTML}}return%20""}function%20ds(a,b){a=a[0].toLowerCase();b=b[0].toLowerCase();if(a<b)return%20-1;if(a>b)return%201;return%200}function%20sl(m){var%20l=Array.prototype.slice.call(m.getElementsByTagName("tr"),0);if(!l.length)return;var%20b=l[0].parentNode;var%20s=[];for(var%20i=0;i<l.length;i++){s[i]=[f(l[i]),l[i]]}s=s.sort(ds);for(i=0;i<s.length;i++){b.appendChild(s[i][1])}}var%20m=document.getElementById('canvas_frame').contentWindow.document.getElementById(":on");if(m)sl(m)})() "SortGmailBySender Bookmarklet") A few caveats of this snippet (and the original) 1. This will screw up your checkbox selection order. Shift clicking to select multiple messages will no longer work until you refresh the view 2. If you archive or delete messages in this view, they will not disappear until you refresh gmail, but remember you can do a much lighter refresh by simply hitting the internal gmail 'refresh' link, rather than F5. 3. I had to change the table selector from ":op" in the original to ":on" in the new version. gmail code changes regularly so you may have to tweak code a little.
Initial Title
Sort Gmail Messages By Sender
Initial Tags
javascript, sort
Initial Language
JavaScript