// ==UserScript==
// @name          SoftPedia Warn Hack
// @author        Ciuly  
// @namespace     http://www.ciuly.com
// @description   places necessary warn related shortcuts where they are not present
// @include       http://forum.softpedia.com/index.php?showtopic=*
// @include       http://forum.softpedia.com/index.php?showuser=*
// @include       http://forum.softpedia.com/index.php?act=Msg&CODE=03&VID=in&MSID=*
// @require       http://www.ciuly.com/greasemonkey/aa_all_common.user.js
// @require       http://www.ciuly.com/greasemonkey/aa_sp_common.user.js
// @require       http://www.ciuly.com/greasemonkey/aa_sp_mod_common.user.js
// ==/UserScript==

(function(){
  var table, tables, span, uid, text, ok;

  var divs = document.getElementsByTagName("div");
  var div;

  ok = false;

  for (var i = 0; i<divs.length; i++){
    div = divs.item(i);
    if (div.className == "pp-name"){
      text = window.location.href;
      var j = text.indexOf("showuser=");
      if (j>-1){
        uid = text.substr(j+9, text.length);
        td = div.getElementsByTagName("td").item(1);
        td.innerHTML = td.innerHTML + "Warn: (<a href=\"javascript:PopUp('http://forum.softpedia.com/index.php?act=warn&amp;mid=" + uid + "&amp;CODE=view','Pager','500','450','0','1','1','1')\">??</a>%) <a href='http://forum.softpedia.com/index.php?act=warn&amp;type=minus&amp;mid=" + uid + "&amp;t=&amp;st=0' title='Decrease warn level'><img src='style_images/1/warn_minus.gif' border='0'  alt='-' /></a><img src='style_images/1/warn0.gif' border='0'  alt='-----' /><a href='http://forum.softpedia.com/index.php?act=warn&amp;type=add&amp;mid=" + uid + "&amp;t=&amp;st=0' title='Increase warn level'><img src='style_images/1/warn_add.gif' border='0'  alt='+' /></a>";
    
        ok = true;
        break; 
      }
    }
 }

  if (ok)
    return;

  tables = document.getElementsByTagName("table");

  for (var i = 0; i<tables.length; i++){
    table = tables.item(i);
    if (table.className == "ipbtable" && table.getAttribute("cellspacing") == "1"){
      aa = table.getElementsByTagName("a");
      if (aa.length == 0) {
        continue;
      }
      text = aa.item(1).getAttribute("href");
      var j = text.indexOf("showuser=");
      if (j>-1){
        uid = text.substr(j+9, text.length);

        span = table.getElementsByTagName("tr").item(1).getElementsByTagName("span").item(0);
        text = span.innerHTML;
        j = text.indexOf("Warn:");
        if (j == -1)
          span.innerHTML = span.innerHTML + "Warn: (<a href=\"javascript:PopUp('http://forum.softpedia.com/index.php?act=warn&amp;mid=" + uid + "&amp;CODE=view','Pager','500','450','0','1','1','1')\">??</a>%) <a href='http://forum.softpedia.com/index.php?act=warn&amp;type=minus&amp;mid=" + uid + "&amp;t=&amp;st=0' title='Decrease warn level'><img src='style_images/1/warn_minus.gif' border='0'  alt='-' /></a><img src='style_images/1/warn0.gif' border='0'  alt='-----' /><a href='http://forum.softpedia.com/index.php?act=warn&amp;type=add&amp;mid=" + uid + "&amp;t=&amp;st=0' title='Increase warn level'><img src='style_images/1/warn_add.gif' border='0'  alt='+' /></a>";
      }
    }
  }


})();