// ==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=*
// ==/UserScript==

var table, tables, span, uid, text;

tables = document.getElementsByTagName("table");

for (var i = 0; i<tables.length; i++){
  table = tables.item(i);
  if (table.className == "ipbtable" & table.getAttribute("cellspacing") == "1"){
    if (table.getElementsByTagName)
      aa = table.getElementsByTagName("a");
    else
      aa = table.all.tags("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){
        var r = document.createRange();
        span.appendChild( document.createTextNode("Warn: (") );
	var nn = document.createElement("a");
	nn.href = "javascript:PopUp('http://forum.softpedia.com/index.php?act=warn&mid=" + uid + "&CODE=view','Pager','500','450','0','1','1','1')";
	nn.appendChild( document.createTextNode("??") );
        span.appendChild( nn );

        span.appendChild( document.createTextNode("%) ") );
  	nn = document.createElement("a");
	nn.href = "http://forum.softpedia.com/index.php?act=warn&type=minus&mid=" + uid + "&t=&st=0";
	nn.title = "Decrease warn level";
	var nnn = document.createElement("img");
	nnn.src = "style_images/1/warn_minus.gif";
	nnn.border = "0";
	nnn.alt = "-";
	nn.appendChild( nnn );
	span.appendChild( nn );

	nn = document.createElement("img");
	nn.src = "style_images/1/warn0.gif";
	nnn.border = "0";
	nnn.alt = "-----";
	span.appendChild( nn );

	nn = document.createElement("a");
	nn.href = "http://forum.softpedia.com/index.php?act=warn&type=add&mid=" + uid + "&t=&st=0";
	nn.title = "Increase warn level";
	
	nnn = document.createElement("img");
	nnn.src = "style_images/1/warn_add.gif";
	nnn.border = "0";
	nnn.alt = "+";
	nn.appendChild( nnn );

	span.appendChild( nn );
      }
    }
  }
}


