// ==UserScript==
// @name          Bloglists
// @namespace     http://sniggle.net/
// @description   adds "From:" info to Bloglines title-only mailing list display
// @include       http://www.bloglines.com/myblogs_display?sub=*
// @include       http://www.bloglines.com/myblogs_display?folder=*
// @include       http://bloglines.com/myblogs_display?sub=*
// @include       http://bloglines.com/myblogs_display?folder=*
// @include       https://www.bloglines.com/myblogs_display?sub=*
// @include       https://www.bloglines.com/myblogs_display?folder=*
// @include       https://bloglines.com/myblogs_display?sub=*
// @include       https://bloglines.com/myblogs_display?folder=*
// ==/UserScript==
// Purpose: Append the "From:" information to the titles of mailing list
//          entries, so that you can tell who sent the item when the list is
//          in its collapsed, title-only form. (Updated 11 July 2006)

// Notes (from last time I checked - this stuff changes often):
//   The list of articles is in a <div> of class "item"
//     found in HTML>BODY>DIV[2] as DIV[1]  (starting from 0)
//   The 2nd child in that <div> is a <div> of id="items9999999" (9=some #)
//   The 2nd child in that <div> is a <table>
//   That table's 2nd child is a <tbody> with one <tr>/<td> per article
//   Inside that <td> is a <div> of id="siteItem.Z.X"
//        (Z = 0..m, where m=#ofsitesonpage)
//        (X = 0..n, where n=#ofarticlesonsite)
//   That <div> has seven children:
//     #text
//     <a id="article-9999999-9999"> the [+/-] expander?
//     #text
//     <h3>.<a>[2].innerHTML = email title 
//     #text
//     <div id="item.9999999.9999">        the article text
//     #text
//   That <h3> has three children:  <a> #text <a>
//   That <div>'s second child is a <p> (class="author")
//   The first three children of the <p> are the "by line" you're looking for:
//     #text.nodeValue +
//     <a>.childNodes[0].nodeValue +
//     #text.nodeValue

var site = 0;

while( siteItemDiv = document.getElementById( "siteItem."+site+".0" ) )
{
  var item = 0;
  while( siteItemDiv = document.getElementById( "siteItem."+site+"."+item ) )
  {
    var h3s = siteItemDiv.getElementsByTagName("h3");
    var paras = siteItemDiv.getElementsByTagName("p");
    for(var i=0; i<paras.length; i++)
    {
      if ( paras[i].className == "author" )
      {
        siteItemTitle  = h3s[0];
        if( paras[i].childNodes.length > 2 )
        {
          siteItemByline = paras[i].childNodes[0].nodeValue
                          + paras[i].childNodes[1].childNodes[0].nodeValue
                          + paras[i].childNodes[2].nodeValue;
          var newp = document.createElement("small");
          newp.appendChild( document.createTextNode( " - "+siteItemByline ) );
          siteItemTitle.appendChild( newp );
        }
      }
    }
    item++;
  }
  site++;
}
