function addDownloadButton() {
  if (document.getElementById("vinlyee-download-btn")) return;

  let actions = document.querySelector("#top-level-buttons-computed");
  if (!actions) return;

  let btn = document.createElement("button");
  btn.innerText = "Download with Vinlyee";
  btn.id = "vinlyee-download-btn";
  btn.style.cssText = `
    background:#f97316;
    color:white;
    border:none;
    border-radius:6px;
    padding:8px 12px;
    margin-left:8px;
    cursor:pointer;
  `;

  btn.onclick = () => {
    let videoUrl = window.location.href;
    chrome.runtime.sendMessage({ action: "openPopup", videoUrl });
  };

  actions.appendChild(btn);
}

setInterval(addDownloadButton, 2000);
