document.addEventListener("DOMContentLoaded", () => { // Initialize Tippy const isMobile = window.matchMedia("(max-width: 768px)").matches; document.querySelectorAll("[data-tippy-content]").forEach((el) => { if (isMobile) { el.setAttribute("data-tippy-placement", "top"); } tippy(el, { placement: el.getAttribute("data-tippy-placement") || "top", arrow: true, delay: [0, 0], duration: [250, 0], allowHTML: true, interactive: true, theme: "surfer", flip: !isMobile, popperOptions: { modifiers: [ { name: "preventOverflow", options: { boundary: "viewport", padding: 8 }, }, ], }, }); }); // Form inputs, canonical, details, marquee logic const pageTitleInputs = document.querySelectorAll('[data-form="input-source"]'); const pageURLInputs = document.querySelectorAll('[data-form="input-source-url"]'); const pageTitle = document.title; const pageURL = window.location.href; pageTitleInputs.forEach((input) => (input.value = pageTitle)); pageURLInputs.forEach((input) => (input.value = pageURL)); let currentUrl = location.protocol + "//" + location.host + location.pathname; if (!currentUrl.endsWith("/")) currentUrl += "/"; // Ensure canonical link is not added multiple times if script runs again if (!document.querySelector(`link[rel="canonical"][href="${currentUrl}"]`)) { document.head.insertAdjacentHTML("beforeend", `<link rel="canonical" href="${currentUrl}"/>`); } const firstDetails = document.querySelector("details"); if (firstDetails) firstDetails.open = true; const marquees = document.querySelectorAll("[marquee]"); marquees.forEach((marquee) => { const tracks = marquee.querySelectorAll("[marquee-track]"); if (tracks.length === 1) { // Only clone if exactly one track exists const clone = tracks[0].cloneNode(true); marquee.appendChild(clone); } }); });