import React, { useState } from "react"; import { Button } from "../ui"; import { ExternalLink, Shield } from "lucide-react"; import { addSkippedHostname } from "../../store/preferences"; interface ExternalLinkModalProps { isOpen: boolean; onClose: () => void; url: string | null; } export default function ExternalLinkModal({ isOpen, onClose, url, }: ExternalLinkModalProps) { const [dontAskAgain, setDontAskAgain] = useState(false); if (!isOpen || !url) return null; const displayUrl = url.split("#:~:text=")[0]; const handleContinue = () => { if (dontAskAgain && url) { try { const hostname = new URL(url).hostname; addSkippedHostname(hostname); } catch (e) { console.error("Invalid URL", e); } } window.open(url, "_blank", "noopener,noreferrer"); onClose(); }; const hostname = (() => { try { return new URL(url).hostname; } catch { return "this site"; } })(); return (
e.stopPropagation()} >

Leaving Margin

You're about to visit an external site.

{displayUrl}
); }