NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name HorseLinkFixer // @namespace cryptal // @description For Howrse: Changes the links to a horses parents to the personal pages, with links to the public pages // @author CryptalEquine // @include */elevage/chevaux/cheval?id=* // @include */elevage/fiche/?id=* // @version 1.2 // @run-at document-start // @noframes true // @grant GM_log // @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js // @require https://gist.githubusercontent.com/BrockA/2625891/raw/9c97aa67ff9c5d56be34a55ad6c18a314e5eb548/waitForKeyElements.js // ==/UserScript== waitForKeyElements("strong:contains('Producer:')", ChangeHorseLink, false); waitForKeyElements("#origins-body-content a.horsename[href*='fiche/?id']", ChangeParentLinks, false); function ChangeHorseLink(e) { var s = ''; if (location.href.contains('/elevage/chevaux/cheval?id=')) s = '<strong><a href="' + toFiche(location.href) + '">Public view</a></strong>'; if (location.href.contains('/elevage/fiche/?id=')) s = '<strong><a href="' + fromFiche(location.href) + '">Owner view</a></strong>'; e.parent().parent().find("td[class*='align-right']").html(s); } function ChangeParentLinks(e) { var url = e.attr('href'); e.attr('href', fromFiche(url)); e.parent().append(' <a href="' + url + '">(public view)</a>'); } function toFiche(u) { return u.replace('chevaux/cheval', 'fiche/'); } function fromFiche(u) { return u.replace('fiche/', 'chevaux/cheval'); } String.prototype.contains = function(e) { return this.indexOf(e) > -1; };