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.
目前為
// ==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 6
// ==/UserScript==
parents = document.getElementsByClassName('horsename');
container = document.getElementById("affix-body-content");
familyDiv = document.createElement("div");
indCC = document.URL.indexOf(".");
//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) owner = 1;
else owner = -1;
if(parents.length == 2)
{
sire = document.createElement("a");
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[0].href.indexOf("="),parents[1].href.length));
sire.appendChild(document.createTextNode("Sire"));
dam.appendChild(document.createTextNode("Dam"));
familyDiv.appendChild(sire);
familyDiv.appendChild(document.createTextNode(" || "));
familyDiv.appendChild(dam);
}
if(document.URL.indexOf("&") < 0)
{
if(document.URL.indexOf("=") > 45)
{
horsePublic = document.createElement("a");
horsePublic.setAttribute("href",document.URL.substring(0,indCC)+".howrse.com/elevage/fiche/?id"+document.URL.substring(document.URL.indexOf("="),document.URL.length));
horsePublic.appendChild(document.createTextNode("Public URL"));
if(parents.length == 2) familyDiv.appendChild(document.createTextNode(" || "));
familyDiv.appendChild(horsePublic);
}
else if(owner == 1)
{
horsePrivate = document.createElement("a");
horsePrivate.setAttribute("href",document.URL.substring(0,indCC)+".howrse.com/elevage/chevaux/cheval?id"+document.URL.substring(document.URL.indexOf("="),document.URL.length));
horsePrivate.appendChild(document.createTextNode("Private URL"));
if(parents.length == 2) familyDiv.appendChild(document.createTextNode(" || "));
familyDiv.appendChild(horsePrivate);
}
}
container.appendChild(familyDiv);