From 6bb6b3a1eaf3565f0db112fbcbd30f7418456ba5 Mon Sep 17 00:00:00 2001 From: kiskaadee Date: Fri, 25 Sep 2026 16:45:28 -0500 Subject: [PATCH] feat(popup): add toolbar action popup for link inspection and manual input - Detect stored captured magnet link and show status indicator - Provide Continue button to launch pairing page with captured link - Add manual entry field and demo link filler for quick testing --- popup.css | 154 +++++++++++++++++++++++++++++++++++++++++++++++++++++ popup.html | 48 +++++++++++++++++ popup.js | 56 +++++++++++++++++++ 3 files changed, 258 insertions(+) create mode 100644 popup.css create mode 100644 popup.html create mode 100644 popup.js diff --git a/popup.css b/popup.css new file mode 100644 index 0000000..ca9e748 --- /dev/null +++ b/popup.css @@ -0,0 +1,154 @@ +* { + box-sizing: border-box; + margin: 0; + padding: 0; +} + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; + background-color: #121214; + color: #ededed; + width: 360px; + padding: 16px; +} + +.popup-container { + display: flex; + flex-direction: column; + gap: 14px; +} + +.header { + display: flex; + align-items: center; + justify-content: space-between; + border-bottom: 1px solid #27272a; + padding-bottom: 10px; +} + +.brand { + display: flex; + align-items: center; + gap: 8px; +} + +.icon { + font-size: 20px; +} + +.title { + font-weight: 700; + font-size: 16px; + color: #e50914; + letter-spacing: 0.5px; +} + +.tag { + font-size: 10px; + text-transform: uppercase; + background: #27272a; + color: #a1a1aa; + padding: 2px 6px; + border-radius: 4px; +} + +.subtitle { + font-size: 12px; + color: #a1a1aa; + line-height: 1.4; + margin-bottom: 10px; +} + +.status-indicator { + display: flex; + align-items: center; + gap: 8px; + margin-bottom: 8px; +} + +.dot { + width: 8px; + height: 8px; + background-color: #22c55e; + border-radius: 50%; + box-shadow: 0 0 8px rgba(34, 197, 94, 0.6); +} + +.status-text { + font-size: 14px; + font-weight: 600; + color: #ffffff; +} + +.magnet-preview { + background: #1c1c1f; + border: 1px solid #2e2e33; + border-radius: 8px; + padding: 10px; + font-family: monospace; + font-size: 11px; + color: #a1a1aa; + word-break: break-all; + max-height: 70px; + overflow-y: auto; + margin-bottom: 12px; +} + +.input-group input { + width: 100%; + padding: 9px 12px; + background-color: #1c1c1f; + border: 1px solid #3f3f46; + border-radius: 6px; + color: #ffffff; + font-size: 12px; + outline: none; + transition: border-color 0.15s; +} + +.input-group input:focus { + border-color: #e50914; +} + +.actions { + display: flex; + gap: 8px; + margin-top: 10px; +} + +.btn { + display: inline-flex; + align-items: center; + justify-content: center; + gap: 6px; + padding: 8px 14px; + border-radius: 6px; + font-size: 13px; + font-weight: 600; + cursor: pointer; + border: none; + transition: background 0.15s, opacity 0.15s; +} + +.btn-primary { + background: #e50914; + color: #ffffff; + flex: 1; +} + +.btn-primary:hover { + background: #f6121d; +} + +.btn-secondary { + background: #27272a; + color: #d4d4d8; +} + +.btn-secondary:hover { + background: #3f3f46; +} + +.hidden { + display: none !important; +} diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..effb86b --- /dev/null +++ b/popup.html @@ -0,0 +1,48 @@ + + + + + Magnetflix + + + + + + + diff --git a/popup.js b/popup.js new file mode 100644 index 0000000..6dcfae8 --- /dev/null +++ b/popup.js @@ -0,0 +1,56 @@ +// popup.js for Magnetflix toolbar popup +const browserAPI = window.browser || window.chrome; + +const SAMPLE_MAGNET = "magnet:?xt=urn:btih:1234567890abcdef1234567890abcdef12345678&dn=Perfect.Blue.1997.1080p.BluRay.x264"; + +document.addEventListener("DOMContentLoaded", () => { + const capturedPanel = document.getElementById("captured-state"); + const manualPanel = document.getElementById("manual-state"); + const magnetDisplay = document.getElementById("magnet-display"); + const manualInput = document.getElementById("manual-magnet-input"); + const btnContinueCaptured = document.getElementById("btn-continue-captured"); + const btnContinueManual = document.getElementById("btn-continue-manual"); + const btnLoadDemo = document.getElementById("btn-load-demo"); + + let currentCapturedMagnet = ""; + + // Check if a magnet was captured recently (within last 24h) + browserAPI.storage.local.get(["lastMagnet", "lastCapturedAt"], (result) => { + if (result && result.lastMagnet) { + currentCapturedMagnet = result.lastMagnet; + magnetDisplay.textContent = currentCapturedMagnet; + capturedPanel.classList.remove("hidden"); + } + }); + + function openApp(magnetUrl) { + browserAPI.runtime.sendMessage( + { + action: "open_app", + magnet: magnetUrl + }, + () => { + window.close(); + } + ); + } + + btnContinueCaptured.addEventListener("click", () => { + if (currentCapturedMagnet) { + openApp(currentCapturedMagnet); + } + }); + + btnContinueManual.addEventListener("click", () => { + const val = manualInput.value.trim(); + if (val) { + openApp(val); + } else { + manualInput.focus(); + } + }); + + btnLoadDemo.addEventListener("click", () => { + manualInput.value = SAMPLE_MAGNET; + }); +});