(() => {
  const markReady = () => {
    const root = document.documentElement;
    if (!root) return false;
    root.dataset.hiroPlayExtension = chrome.runtime.getManifest().version;
    window.dispatchEvent(new Event("hiroplay:extension-ready"));
    return true;
  };
  if (!markReady()) {
    const observer = new MutationObserver(() => {
      if (markReady()) observer.disconnect();
    });
    observer.observe(document, { childList: true, subtree: true });
  }
})();
