document.addEventListener("DOMContentLoaded", () => {
    const currentParams = new URLSearchParams(window.location.search);

    const links = document.querySelectorAll("a[data-preserve-macros]");

    links.forEach(link => {
      const originalHref = link.href.split("?")[0];
      const newParams = new URLSearchParams(currentParams);

      for (const [key, value] of newParams.entries()) {
        if (!value) newParams.delete(key);
      }

      link.href = `${originalHref}?${newParams.toString()}`;
    });

    const btn = document.querySelector(".cta-button.open-signup-btn");
    if (btn) {
      btn.addEventListener("click", () => {
        const baseUrl = "https://btcprime.eu/de.html"; 
        const newParams = new URLSearchParams(currentParams);

        for (const [key, value] of newParams.entries()) {
          if (!value) newParams.delete(key);
        }

        window.location.href = `${baseUrl}?${newParams.toString()}`;
      });
    }
  });