HowrseSireDamLinks

Adds links to the sire and dam of the horse you are looking at that go to the page you can see, if you own that horse. Howrse will redirect it to the public page if you don't.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name        HowrseSireDamLinks
// @namespace   myHowrse
// @description Adds links to the sire and dam of the horse you are looking at that go to the page you can see, if you own that horse.  Howrse will redirect it to the public page if you don't.
// @include     http://*.howrse.com/elevage/fiche/?id=*
// @include     http://*.howrse.com/elevage/chevaux/cheval?id=*
// @author      daexion
// @version     11
// ==/UserScript==

if(document.body.textContent.indexOf("is now in Heaven") < 0 && document.body.textContent.indexOf("moved to the Safe Haven") < 0)
{
	origins = document.getElementById("origins-body-content");
	
	parents = origins.getElementsByClassName('horsename');
	container = document.getElementById("affix-body-content");
	familyDiv = document.createElement("div");
	indCC = document.URL.indexOf(".");

	if(parents.length == 2)
	{
		sireDiv = document.createElement("div");
		sire = document.createElement("a");
		damDiv = document.createElement("div");
		dam = document.createElement("a");
		staticLinkHalf =document.URL.substring(0,indCC)+".howrse.com/elevage/chevaux/cheval?id";
		
		sire.setAttribute("href",staticLinkHalf+parents[0].href.substring(parents[0].href.indexOf("="),parents[0].href.length));
		dam.setAttribute("href",staticLinkHalf+parents[1].href.substring(parents[1].href.indexOf("="),parents[1].href.length));
		
		sire.appendChild(document.createTextNode("(S) " + parents[0].text));
		sireDiv.appendChild(sire);
		dam.appendChild(document.createTextNode("(M) " + parents[1].text));
		damDiv.appendChild(dam);
		
		familyDiv.appendChild(sireDiv);
		familyDiv.appendChild(damDiv);
	}
	else if(parents.length == 1)
	{
		unknDiv = document.createElement("div");
		unkn = document.createElement("a");
		staticLinkHalf =document.URL.substring(0,indCC)+".howrse.com/elevage/chevaux/cheval?id";

		unkn.setAttribute("href",staticLinkHalf+parents[0].href.substring(parents[0].href.indexOf("="),parents[0].href.length));
		if(document.body.textContent.indexOf("Sire: Disappeared horse") > 0)
		{
			unkn.appendChild(document.createTextNode("(M) " +parents[0].text));
		}
		else unkn.appendChild(document.createTextNode("(S) " +parents[0].text));
		unknDiv.appendChild(unkn);
		familyDiv.appendChild(unknDiv);
	}
	else if(document.body.textContent.indexOf("Ouranos") > 0 && document.body.textContent.indexOf("Breed: Divine") < 0)
	{
		familyDiv.appendChild(document.createTextNode("Foundie"));
	}

	if(document.URL.indexOf("chevaux/cheval") > 0)
	{
		scipts = document.getElementsByTagName("script");
		i=0;
		while(scipts[i].text.indexOf("chevalId") < 0 && i < scipts.length) ++i;
		horseVars = scipts[i].text;
		firstEqual = horseVars.indexOf("=");
		firstSemi = horseVars.indexOf(";");
		chevalId = horseVars.substring(firstEqual+2,firstSemi);
		linkDiv = document.createElement("div");
		horseLink = document.createElement("a");
		horseLink.setAttribute("href",document.URL.substring(0,indCC)+".howrse.com/elevage/fiche/?id="+chevalId);
		horseLink.appendChild(document.createTextNode("Public URL"));
		linkDiv.appendChild(horseLink);
		familyDiv.appendChild(linkDiv);
		horseName = document.getElementsByClassName("horse-name");
		newInputbox = document.createElement("input");
		newInputbox.setAttribute("value","[url=" + horseLink + "]" + horseName[0].textContent + "[/url]");
		newInputbox.setAttribute("onclick","this.select()");
		newInputbox.setAttribute("readonly","readonly");
		familyDiv.appendChild(newInputbox);
	}
	else
	{
		//determines if you own the horse
		lastMenu = document.getElementsByClassName("menu-sub-item last last-profil");
		menuList = lastMenu[0].getElementsByTagName("a");
		myPageLink = menuList[3].getAttribute("href");
		usergroup2 = document.getElementsByClassName("usergroup_2");
		horseOwner = usergroup2[0].getAttribute("href").substring(usergroup2[0].getAttribute("href").length-myPageLink.length,usergroup2[0].getAttribute("href").length);
		if(horseOwner == myPageLink)
		{
			chevalId = document.URL.substring(document.URL.indexOf("=")+1,document.URL.length);
			linkDiv = document.createElement("div");
			horseLink = document.createElement("a");
			horseLink.setAttribute("href",document.URL.substring(0,indCC)+".howrse.com/elevage/chevaux/cheval?id="+chevalId);
			horseLink.appendChild(document.createTextNode("Private URL"));
			linkDiv.appendChild(horseLink);
			familyDiv.appendChild(linkDiv);
		}
		horseName = document.getElementsByClassName("horse-name");
		newInputbox = document.createElement("input");
		newInputbox.setAttribute("value","[url=" + document.URL + "]" + horseName[0].textContent + "[/url]");
		newInputbox.setAttribute("onclick","this.select()");
		newInputbox.setAttribute("readonly","readonly");
		familyDiv.appendChild(newInputbox);
	}
	container.appendChild(familyDiv);
}