. - Shows ONLY on the homepage paths listed in MATCH_PATHS. - Works across AJAX transitions via MutationObserver + popstate. */ (function () { var MATCH_PATHS = ['/home', '']; // '/home' and '/' (root) just in case var btn = document.getElementById('remark-bsl-button'); function mountToBody(el){ if(el && el.parentNode !== document.body){ try{ document.body.appendChild(el);}catch(e){} } } function cleanPath(p){ return (p || location.pathname).replace(/\/+$/,''); } function shouldShow(){ return MATCH_PATHS.indexOf(cleanPath()) > -1; } function applyVisibility(){ mountToBody(btn); if (!btn) return; btn.style.display = shouldShow() ? 'block' : 'none'; } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', applyVisibility); } else { applyVisibility(); } window.addEventListener('popstate', function(){ setTimeout(applyVisibility, 50); }); new MutationObserver(function(){ clearTimeout(window.__remarkBslTO); window.__remarkBslTO = setTimeout(applyVisibility, 80); }).observe(document.documentElement, { childList:true, subtree:true }); })();