import cssText from "data-text:~style.content.css"; import { sendToBackground } from "@plasmohq/messaging"; import type { PlasmoCSConfig } from "plasmo"; import React from "react"; import AlertError from "~lib/components/AlertError"; import LoadingCards from "~lib/components/LoadingCards"; import Modal from "~lib/components/Modal"; import { MESSAGE_NAMES } from "~lib/constants"; import { useRetrieveBskyUsers } from "~lib/hooks/useRetrieveBskyUsers"; export const config: PlasmoCSConfig = { matches: ["https://twitter.com/*", "https://x.com/*"], all_frames: true, }; export const getStyle = () => { const style = document.createElement("style"); // patch for shadow dom style.textContent = cssText.replaceAll(":root", ":host"); return style; }; const App = () => { const { initialize, modalRef, users, loading, stopRetrieveLoop, restart, isBottomReached, errorMessage, listName, } = useRetrieveBskyUsers(); React.useEffect(() => { const messageHandler = ( message: { name: (typeof MESSAGE_NAMES)[keyof typeof MESSAGE_NAMES]; }, _sender: chrome.runtime.MessageSender, sendResponse: (response?: Record) => void, ) => { if (Object.values(MESSAGE_NAMES).includes(message.name)) { initialize() .then(() => { sendResponse({ hasError: false }); }) .catch((e) => { console.error(e); sendResponse({ hasError: true, message: e.toString() }); }); return true; } return false; }; chrome.runtime.onMessage.addListener(messageHandler); return () => { chrome.runtime.onMessage.removeListener(messageHandler); }; }, [initialize]); const openOptionPage = () => { sendToBackground({ name: "openOptionPage" }); }; const stopAndShowDetectedUsers = async () => { stopRetrieveLoop(); await chrome.storage.local.set({ users: JSON.stringify(users), listName: listName }); openOptionPage(); }; return ( <>
{loading && (

Scanning 𝕏 users to find bsky users...

)}

Detected {users.length} users

{errorMessage && {errorMessage}} {loading && ( <> )} {!loading && !isBottomReached && ( )} {!loading && isBottomReached && (
)}
); }; export default App;