// ==UserScript==
// @name          strawberry2 img append
// @namespace     http://blog.fkoji.com/
// @description	  add images of strawberry2 to rss reader
// @include       http://www.bloglines.com/myblogs_display*
// ==/UserScript==

(function() {
  var url = [];
  var desc = [];
  var a = document.getElementsByTagName("a");
  for (var i = 0; i < a.length; i++) {
    if (a[i].className == "bl_itemtitle") {
      url.push(a[i].href);
    }
  }
  var td = document.getElementsByTagName("td");
  for (var i = 0; i < td.length; i++) {
    if (td[i].className == "article") {
      desc.push(td[i]);
    }
  }

  var reqCount = 0;
  var resCount = 0;
  function request() {
    GM_xmlhttpRequest({method: "post", url: url[reqCount], onload: appendImage});
    reqCount++;
  }
  function appendImage(body) {
    body.responseText.match(/<div style="text\-align: center;"><img src="([^"]+)" border="0"><\/div>/);
    var img = document.createElement("img");
    img.src = "http://yaplog.jp" + RegExp.$1;
    desc[resCount].appendChild(img);
    resCount++;
  }

  for (var i = 0; i < url.length; i++) {
    if (url[i].match(/^http:\/\/yaplog\.jp\/strawberry2\//)) {
      window.setTimeout(request, 1000 * i);
    }
  }
})();

