/* BT player linker v1.2: links player names on trackers to /players// using bt-player-index.json (MLB id -> slug, unique full name -> slug). */ (function(){var IDX=window.BT_PIDX_URL||'https://storage.ghost.io/c/f2/85/f285ce72-40e3-409f-ae3b-2ef371936c02/content/files/2026/10/bt-player-index.json',RE=/\/people\/(\d+)\//,NP=/^\/prospect-rankings-live\/$/; if(/^\/(players|ghost)\//.test(location.pathname))return; var D=null,T=0; function nk(s){return String(s||'').normalize('NFD').replace(/[̀-ͯ]/g,'').toLowerCase().replace(/[^a-z ]/g,'').replace(/\s+/g,' ').trim()} function mk(s){var a=document.createElement('a');a.href='/players/'+s+'/';a.className='bt-pl';return a} function link(el,s){var a=mk(s);while(el.firstChild)a.appendChild(el.firstChild);el.appendChild(a)} function wrapT(n,s){var a=mk(s);n.parentNode.insertBefore(a,n);a.appendChild(n)} function run(){T=0;if(!D)return;var root=document.querySelector('.gh-content')||document.body; [].forEach.call(root.querySelectorAll('img'),function(im){if(im.getAttribute('data-bpl'))return;var m=RE.exec(im.src||'');if(!m)return;im.setAttribute('data-bpl','1');var s=D.p[m[1]];if(!s||im.closest('a,.bpc-pchip,.bpc-dd'))return; var c=im.closest('td,th,.btt-who,h3,li')||im.parentElement;if(c.querySelector('a[href*="/players/"]'))return; var t=c.querySelector('strong,b');if(t&&!t.closest('a')){link(t,s);return} var n=im.nextSibling;while(n&&!((n.nodeType===3&&n.textContent.trim())||(n.nodeType===1&&/^(DIV|SPAN)$/.test(n.tagName)&&n.textContent.trim())))n=n.nextSibling; if(!n)return;if(n.nodeType===3){wrapT(n,s);return} var e=n;for(var g=0;e&&g<6;g++){var f=e.firstChild;while(f&&!((f.nodeType===3&&f.textContent.trim())||f.nodeType===1))f=f.nextSibling;if(!f)return;if(f.nodeType===3){if(!f.parentNode.closest('a'))wrapT(f,s);return}if(/^(SMALL|BUTTON|IMG)$/.test(f.tagName))return;e=f}}); if(NP.test(location.pathname))[].forEach.call(root.querySelectorAll('span,td,strong,b,div,h3,h4'),function(e){if(e.children.length||e.getAttribute('data-bpl')||e.closest('a'))return;var s=D.n[nk(e.textContent)];if(s){e.setAttribute('data-bpl','1');link(e,s)}})} function q(){T||(T=setTimeout(run,250))} var st=document.createElement('style');st.textContent='a.bt-pl{color:inherit;text-decoration:none}a.bt-pl:hover{color:#3b82f6;text-decoration:underline}';document.head.appendChild(st); fetch(IDX).then(function(r){return r.json()}).then(function(j){D=j;run();new MutationObserver(q).observe(document.body,{childList:true,subtree:true})}).catch(function(){})})();