import type { PlasmoCSConfig, PlasmoGetInlineAnchor, PlasmoGetStyle } from "plasmo"; import { Sparkles, X } from "lucide-react"; import { useState, useEffect } from "react"; import { createRoot } from "react-dom/client"; /** * Floating Quick Action Button (like Mevx) * Appears on crypto-related pages for quick token analysis */ export const config: PlasmoCSConfig = { matches: [ "*://dexscreener.com/*", "*://www.dexscreener.com/*", "*://twitter.com/*", "*://x.com/*", "*://coingecko.com/*", "*://www.coingecko.com/*", "*://coinmarketcap.com/*", "*://www.coinmarketcap.com/*", ], }; export const getStyle: PlasmoGetStyle = () => { const style = document.createElement("style"); style.textContent = ` #surfsense-floating-button { all: initial; position: fixed; bottom: 24px; right: 24px; z-index: 999999; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; } #surfsense-floating-popup { all: initial; position: fixed; bottom: 88px; right: 24px; z-index: 999999; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; } `; return style; }; interface TokenQuickInfo { symbol: string; name: string; price: string; change24h: number; chain: string; } function FloatingButton() { const [isOpen, setIsOpen] = useState(false); const [tokenInfo, setTokenInfo] = useState(null); const [isLoading, setIsLoading] = useState(false); useEffect(() => { // Listen for token detection from content script const handleMessage = (message: any) => { if (message.type === "TOKEN_DETECTED") { setTokenInfo(message.data); } }; chrome.runtime.onMessage.addListener(handleMessage); return () => chrome.runtime.onMessage.removeListener(handleMessage); }, []); const handleButtonClick = async () => { if (!isOpen) { setIsLoading(true); // Simulate fetching quick token info setTimeout(() => { setTokenInfo({ symbol: "BONK", name: "Bonk", price: "$0.00001234", change24h: 156.7, chain: "Solana", }); setIsLoading(false); }, 500); } setIsOpen(!isOpen); }; const handleOpenSidepanel = () => { chrome.runtime.sendMessage({ type: "OPEN_SIDEPANEL" }); setIsOpen(false); }; return ( <> {/* Floating Button */}
{/* Quick Info Popup */} {isOpen && (
{isLoading ? (
Loading...
) : tokenInfo ? ( <>
{tokenInfo.symbol}
{tokenInfo.name}
{tokenInfo.price}
= 0 ? "#10b981" : "#ef4444", fontWeight: "500", }} > {tokenInfo.change24h >= 0 ? "+" : ""} {tokenInfo.change24h.toFixed(2)}% (24h)
) : (
No token detected
)}
)} ); } export default FloatingButton;