// ==UserScript==
// @name            Nofollow Notifier
// @namespace       http://www.newshoemedia.com/blog/
// @description     Styles nofollow links with a pink background
// @include         *
// ==/UserScript==

(function () {

  var re = /nofollow/i;
  
  var candidates = document.getElementsByTagName("a");
  
  var metaCandidates = document.getElementsByTagName("meta");
  
  for (var cand = null, i = 0; (cand = candidates[i]); i++)
  {
    if (re.test(cand.getAttribute("rel")))
    {
      theStyle = cand.getAttribute("style");
      if(theStyle == null) { theStyle = ""; }

      theStyle += ";font-weight:normal; background-color: pink; color: #000; border: 0; text-decoration: underline;";
      cand.setAttribute("style",theStyle);

      var imgs = cand.getElementsByTagName("img")
      if (imgs.length > 0)
      {
        for (var j = 0; j < imgs.length; j++)
        {
          imgStyle = imgs[j].getAttribute("style");
          if(imgStyle == null) { imgStyle = ""; }

          imgStyle += ";border-color: pink; border-style: dotted; border-width: 0 0 2px 0;";
          imgs[j].setAttribute("style",imgStyle);
        }
      }
    }
  }
  for (var cand = null, i = 0; (cand = metaCandidates[i]); i++)
  {
    if (re.test(cand.getAttribute("content")))
    {
		var anchorTags = document.getElementsByTagName("a");
		for (var i=0;i<anchorTags.length;i++) {
			anchorTags[i].style.background = "pink";
			anchorTags[i].style.borderBottomColor = "red";
			anchorTags[i].style.borderBottomWidth = "1px";
			anchorTags[i].style.borderBottomStyle = "dotted";
		}
    }
  }

})();
