krisztiantobias / Pmanager.org Division help

// ==UserScript==
// @name          Pmanager.org Division help
// @namespace     http://tampermonkey.net/
// @description   Make 4 new link to every teams
// @include       https://www.pmanager.org/classificacao.asp*
// @version       2.01
// @license MIT
// @grant         none
// ==/UserScript==

let $ = window.$;

$(document).ready(function()
{
	const section = $("section#feature");
	let baseString = "";
	let listType = "";
	let topDivision = false;

	if(section.find("td.team_players").eq(1).text().substr(0,6) == "Legfel")
	{
		topDivision = true;
	}

	section.find("tr.table_header").find("td").eq(3).after("<td width=\"2%\"></td>");
	section.find("tr.table_header").find("td").eq(3).after("<td width=\"2%\"></td>");
	section.find("tr.table_header").find("td").eq(3).after("<td width=\"2%\"></td>");
	section.find("tr.table_header").find("td").eq(3).after("<td width=\"2%\"></td>");

	let counter = 0;
	for (let row = 2; row < 15; ++row)
	{
		let i = row; // weird website this is
		if (!topDivision && i == 2)
		{
			i = 1;
		}

		if( (section.find("tr").eq(i).find("td").eq(3).text()).length > 0 )
		{
			baseString = section.find("tr").eq(i).find("td").eq(3).html();
			if(baseString.length > 0)
			{
				let helper = baseString.indexOf("equipa=",0);
				if(helper > -1)
				{
					baseString = baseString.substr(helper +7 , 5);
					helper = baseString.indexOf("\"",0);
					if(helper > -1)
                    {
						baseString = baseString.substr(0,helper);
                    }

					if(counter == 0)
					{
						counter = 1;
						listType = "list1";
					}
					else
					{
						counter = 0;
						listType = "list2";
					}

					section.find("tr").eq(i).find("td").eq(3).after("<td class=\""+listType+"\" width=\"2%\">"+
					"<a href=\"http://www.pmanager.org/ver_equipa.asp?equipa="+baseString+"&vjog=1\">"+
					"<img title=\"Csapat Kerete\" src=\"http://www.pmanagertutorial.nhely.hu/images/other/list.png\">"+
					"</a>"+
					"</td>");
					section.find("tr").eq(i).find("td").eq(3).after("<td class=\""+listType+"\" width=\"2%\">"+
					"<a href=\"http://www.pmanager.org/mensagens.asp?action=0&dest_id="+baseString+"\">"+
					"<img title=\"Üzenet a Menedzsernek\" src=\"http://www.pmanagertutorial.nhely.hu/images/other/message.png\">"+
					"</a>"+
					"</td>");
					section.find("tr").eq(i).find("td").eq(3).after("<td class=\""+listType+"\" width=\"2%\">"+
					"<a href=\"http://www.pmanager.org/convites.asp?action=oferecer&clube="+baseString+"&fora=0\">"+
					"<img title=\"Kihívás Barátságos Meccsre\" src=\"http://www.pmanagertutorial.nhely.hu/images/other/ball.png\">"+
					"</a>"+
					"</td>");
					section.find("tr").eq(i).find("td").eq(3).after("<td class=\""+listType+"\" width=\"2%\">"+
					"<a href=\"http://www.pmanager.org/calendario.asp?action=equipa&equipa="+baseString+"\">"+
					"<img title=\"Csapat Sorsolása\" src=\"http://www.pmanagertutorial.nhely.hu/images/other/calendar.png\">"+
					"</a>"+
					"</td>");
				}
				else
				{
					helper = baseString.indexOf("info.asp",0);
					if(helper > -1)
					{
						if(counter == 0)
						{
							counter = 1;
							listType = "list1";
						}
						else
						{
							counter = 0;
							listType = "list2";
						}

						section.find("tr").eq(i).find("td").eq(3).after("<td class=\""+listType+"\" width=\"2%\">"+
						"<a href=\"http://www.pmanager.org/plantel.asp\">"+
						"<img title=\"Csapat Kerete\" src=\"http://www.pmanagertutorial.nhely.hu/images/other/list.png\">"+
						"</a>"+
						"</td>");
						section.find("tr").eq(i).find("td").eq(3).after("<td class=\""+listType+"\" width=\"2%\"></td>");
						section.find("tr").eq(i).find("td").eq(3).after("<td class=\""+listType+"\" width=\"2%\"></td>");
						section.find("tr").eq(i).find("td").eq(3).after("<td class=\""+listType+"\" width=\"2%\">"+
					"<a href=\"http://www.pmanager.org/calendario.asp?action=equipa\">"+
					"<img title=\"Csapat Sorsolása\" src=\"http://www.pmanagertutorial.nhely.hu/images/other/calendar.png\">"+
					"</a>"+
					"</td>");
					}
				}
			}
		}
		else
		{
		// does not work properly
			section.find("tr").eq(i).html("<td colspan=\"16\" style=\"background-color: black; padding: 0px;\" height=\"1px\"></td>");
		}
	}

}); // ready