/* BT player service time & options v2 (player pages): adds "Service time" (years.days, Cot's) and "Options left" (only under 5.000 years, when a player can still be optioned without his consent) to the banner, from window.BT_SVC_URL. Also swaps an old minor-league headshot for the MLB one when the player has debuted. */ (function(){var el=document.getElementById('bt-player');if(!el)return;var id=el.getAttribute('data-mlbam'); function shot(){var i=document.querySelector('img.btp-shot'),sb=document.querySelector('.btp-subbar');if(i&&sb&&/\/headshot\/milb\//.test(i.src)&&/MLB debut/i.test(sb.textContent)){var m=i.src.replace('/headshot/milb/','/headshot/67/');i.src=m}} function add(d){var sb=document.querySelector('.btp-subbar');if(!sb||sb.querySelector('.btp-svc'))return !!sb;var r=d&&d.p&&d.p[id];if(!r)return true;var t='Major-league service time through the 2026 season, in years.days (172 days = 1 year). Source: Cot’s Baseball Contracts.';var h='Service time: '+Number(r[0]).toFixed(3)+'';if(r[0]<5&&r[1]!=null)h+='Options: '+r[1]+(r[1]===0?' (out of options)':'')+'';sb.insertAdjacentHTML('beforeend',h);return true} var data=null,n=0;function tick(){shot();if(data!==null){if(add(data))return}if(++n<60)setTimeout(tick,250)} if(window.BT_SVC_URL)fetch(window.BT_SVC_URL).then(function(r){return r.json()}).then(function(d){data=d}).catch(function(){data=false});else data=false; if(document.readyState==='loading')document.addEventListener('DOMContentLoaded',tick);else tick(); new MutationObserver(function(){if(data&&!document.querySelector('.btp-svc'))add(data);shot()}).observe(document.body,{childList:true,subtree:true});})();