(() => { // Clean up an earlier copy window.oneHitBridge?.close?.(); document.getElementById("onehit-mp4-popup")?.remove(); // Remember processed URLs during this browser page session const sent = window.__oneHitSent || (window.__oneHitSent = { add: new Set(), sub: new Set() }); let currentUrl = ""; let autoSend = false; let busy = false; let maximized = false; const popup = document.createElement("div"); popup.id = "onehit-mp4-popup"; popup.style.cssText = ` position:fixed;right:20px;bottom:20px;width:390px; z-index:2147483647;background:#17191f;color:white; border:1px solid #555;border-radius:10px; box-shadow:0 5px 25px #0009;font:13px Arial,sans-serif; overflow:hidden; `; popup.innerHTML = `
๐ŸŽฌ 1hit MP4 Bridge
Looking for MP4 videos...
`; document.body.appendChild(popup); const $ = id => popup.querySelector("#oh-" + id); const status = $("status"); const urlBox = $("url"); function updateUI() { const endpoint = $("endpoint").value; const done = currentUrl && sent[endpoint].has(currentUrl); $("send").disabled = !currentUrl || done || busy; $("send").textContent = done ? "Already sent โœ“" : endpoint === "add" ? "Send to add.php" : "Send to sub.php"; $("send").style.opacity = $("send").disabled ? ".5" : "1"; $("count").textContent = `Remembered: ${sent.add.size} add.php ยท ${sent.sub.size} sub.php`; } async function sendCurrent(automatic = false) { const url = currentUrl; const endpoint = $("endpoint").value; if (!url || busy || sent[endpoint].has(url)) return; busy = true; updateUI(); status.textContent = `Sending to ${endpoint}.php...`; status.style.color = "#f0c674"; try { let request; if (endpoint === "add") { request = fetch( "https://1hit.no/kaggle/add.php/?url=" + encodeURIComponent(url), { method: "GET", mode: "no-cors" } ); } else { request = fetch("https://1hit.no/kaggle/sub.php", { method: "POST", mode: "no-cors", headers: { "Content-Type": "text/plain;charset=UTF-8" }, body: JSON.stringify({ url, client_id: "Wan2GP-Kaggle" }) }); } await request; // The no-cors response cannot confirm server-side completion. sent[endpoint].add(url); status.textContent = automatic ? `AUTO: request sent to ${endpoint}.php โœ“` : `Request sent to ${endpoint}.php โœ“`; status.style.color = "#70d99a"; } catch (error) { status.textContent = `Request failed: ${error.message}`; status.style.color = "#ff7777"; } finally { busy = false; updateUI(); } } function findVideos() { const urls = [...document.querySelectorAll("video")] .map(v => v.currentSrc || v.src || v.querySelector("source")?.src || "") .filter(url => /^https:\/\//i.test(url) && /\.mp4(?:[?#]|$)/i.test(url) ); const best = urls.find(url => url.includes("/gradio_api/file=")) || urls.at(-1); if (best && best !== currentUrl) { currentUrl = best; urlBox.value = best; status.textContent = "New MP4 detected โœ“"; status.style.color = "#70d99a"; updateUI(); if (autoSend) sendCurrent(true); } } // AUTO SEND toggle $("auto").onchange = () => { autoSend = $("auto").checked; status.textContent = autoSend ? "AUTO SEND enabled โ€” scanning every 10 seconds." : "AUTO SEND disabled โ€” manual mode."; status.style.color = autoSend ? "#70d99a" : "#aaa"; }; $("endpoint").onchange = updateUI; $("send").onclick = () => sendCurrent(false); // Minimize / restore $("min").onclick = () => { const content = $("content"); const hidden = content.style.display === "none"; content.style.display = hidden ? "block" : "none"; $("min").textContent = hidden ? "โ€”" : "+"; }; // Maximize / restore $("max").onclick = () => { maximized = !maximized; if (maximized) { popup.dataset.oldStyle = JSON.stringify({ width: popup.style.width, height: popup.style.height, top: popup.style.top, left: popup.style.left, right: popup.style.right, bottom: popup.style.bottom, borderRadius: popup.style.borderRadius }); popup.style.width = "min(700px, calc(100vw - 30px))"; popup.style.height = "min(85vh, 750px)"; popup.style.top = "50%"; popup.style.left = "50%"; popup.style.right = "auto"; popup.style.bottom = "auto"; popup.style.transform = "translate(-50%, -50%)"; $("content").style.overflow = "auto"; $("content").style.maxHeight = "calc(85vh - 50px)"; $("max").textContent = "โ"; } else { const old = JSON.parse(popup.dataset.oldStyle || "{}"); Object.assign(popup.style, old); popup.style.transform = ""; $("content").style.maxHeight = ""; $("max").textContent = "โ–ก"; } }; // Drag using the header let drag = null; $("head").addEventListener("pointerdown", e => { if (e.target.closest("button") || maximized) return; const rect = popup.getBoundingClientRect(); drag = { x: e.clientX - rect.left, y: e.clientY - rect.top }; $("head").setPointerCapture(e.pointerId); }); $("head").addEventListener("pointermove", e => { if (!drag) return; popup.style.left = `${e.clientX - drag.x}px`; popup.style.top = `${e.clientY - drag.y}px`; popup.style.right = "auto"; popup.style.bottom = "auto"; }); $("head").addEventListener("pointerup", () => drag = null); $("head").addEventListener("pointercancel", () => drag = null); // Scan immediately, then every 10 seconds findVideos(); const timer = setInterval(findVideos, 10000); $("close").onclick = () => { clearInterval(timer); popup.remove(); delete window.oneHitBridge; }; window.oneHitBridge = { scan: findVideos, close: () => $("close").click(), sent }; updateUI(); })();