From 5a6db564473698fa2b148f2115ec52aa65d1b041 Mon Sep 17 00:00:00 2001 From: mondaychen Date: Tue, 18 Jun 2024 16:31:34 -0700 Subject: [PATCH] feat: expose debug mode for main world via content script --- src/common/TaskUI.tsx | 40 ++++++++++++++++++++++++-------------- src/pages/content/index.ts | 2 -- vite.config.ts | 6 +++--- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/common/TaskUI.tsx b/src/common/TaskUI.tsx index 652bdd7..35f8aee 100644 --- a/src/common/TaskUI.tsx +++ b/src/common/TaskUI.tsx @@ -1,10 +1,9 @@ -import React, { useCallback, useState } from "react"; +import React, { useCallback } from "react"; import { Button, Box, HStack, Spacer, - Textarea, useToast, Alert, AlertIcon, @@ -19,6 +18,19 @@ import TaskStatus from "./TaskStatus"; import RecommendedTasks from "./RecommendedTasks"; import AutosizeTextarea from "./AutosizeTextarea"; +const injectContentScript = async () => { + const [tab] = await chrome.tabs.query({ currentWindow: true, active: true }); + if (!tab || !tab.id) { + return; + } + + await chrome.scripting.executeScript({ + target: { tabId: tab.id }, + files: ["src/pages/contentInjected/index.js"], + world: "MAIN", + }); +}; + function ActionExecutor() { const state = useAppState((state) => ({ attachDebugger: state.currentTask.actions.attachDebugger, @@ -27,28 +39,26 @@ function ActionExecutor() { prepareLabels: state.currentTask.actions.prepareLabels, showImagePrompt: state.currentTask.actions.showImagePrompt, })); - const [action, setAction] = useState(`{ - "thought": "try searching", - "action": "click('search')" -} -`); return ( -