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.

当前为 2014-03-28 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name HowrseSireDamLinks
  3. // @namespace myHowrse
  4. // @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.
  5. // @include http://*.howrse.com/elevage/fiche/?id=*
  6. // @include http://*.howrse.com/elevage/chevaux/cheval?id=*
  7. // @author daexion
  8. // @version 5
  9. // ==/UserScript==
  10.  
  11. parents = document.getElementsByClassName('horsename');
  12.  
  13. container = document.getElementById("affix-body-content");
  14. familyDiv = document.createElement("div");
  15. indCC = document.URL.indexOf(".");
  16. if(parents.length == 2)
  17. {
  18. sire = document.createElement("a");
  19. dam = document.createElement("a");
  20. GM_log(indCC);
  21. staticLinkHalf =document.URL.substring(0,indCC)+".howrse.com/elevage/chevaux/cheval?id";
  22.  
  23. sire.setAttribute("href",staticLinkHalf+parents[0].href.substring(parents[0].href.indexOf("="),parents[0].href.length));
  24. dam.setAttribute("href",staticLinkHalf+parents[1].href.substring(parents[0].href.indexOf("="),parents[1].href.length));
  25.  
  26. sire.appendChild(document.createTextNode("Sire"));
  27. dam.appendChild(document.createTextNode("Dam"));
  28.  
  29. familyDiv.appendChild(sire);
  30. familyDiv.appendChild(document.createTextNode(" || "));
  31. familyDiv.appendChild(dam);
  32. }
  33. if(document.URL.indexOf("=") > 40 && document.URL.indexOf("&") < 0)
  34. {
  35. horsePublic = document.createElement("a");
  36. GM_log(indCC);
  37. horsePublic.setAttribute("href",document.URL.substring(0,indCC)+".howrse.com/elevage/fiche/?id"+document.URL.substring(document.URL.indexOf("="),document.URL.length));
  38. horsePublic.appendChild(document.createTextNode("Public URL"));
  39. if(parents.length == 2) familyDiv.appendChild(document.createTextNode(" || "));
  40. familyDiv.appendChild(horsePublic);
  41. }
  42. container.appendChild(familyDiv);