From ed9fcb56e590bdfbba273e24eb6bd0b5307780d3 Mon Sep 17 00:00:00 2001 From: psm1st Date: Tue, 8 Apr 2025 18:17:42 +0900 Subject: [PATCH 1/7] =?UTF-8?q?feat=20:tts=20=EA=B8=B0=EB=8A=A5=20?= =?UTF-8?q?=EC=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/manifest.json | 6 +++ src/popup/component.tsx | 96 +++++++++++++---------------------------- src/popup/index.tsx | 6 +-- 3 files changed, 37 insertions(+), 71 deletions(-) diff --git a/dist/manifest.json b/dist/manifest.json index 8c70e0d..1267091 100644 --- a/dist/manifest.json +++ b/dist/manifest.json @@ -11,6 +11,12 @@ }, "default_popup": "popup.html" }, + "content_scripts": [ + { + "matches": ["https://*/*"], + "js": ["js/contentScript.js"] + } + ], "background": { "service_worker": "js/backgroundPage.js" }, diff --git a/src/popup/component.tsx b/src/popup/component.tsx index f044012..fb77e89 100644 --- a/src/popup/component.tsx +++ b/src/popup/component.tsx @@ -1,74 +1,36 @@ -import React from "react"; -import { Hello } from "@src/components/hello"; -import browser, { Tabs } from "webextension-polyfill"; -import { Scroller } from "@src/components/scroller"; +import React, { useState } from "react"; +import "../css/app.css"; -// // // // +const Component = () => { + const [text, setText] = useState(""); -// Scripts to execute in current tab -const scrollToTopPosition = 0; -const scrollToBottomPosition = 9999999; + const handleSpeak = () => { + if (!text.trim()) return; -function scrollWindow(position: number) { - window.scroll(0, position); -} + const utterance = new SpeechSynthesisUtterance(text); + utterance.lang = "ko-KR"; + speechSynthesis.speak(utterance); + }; -/** - * Executes a string of Javascript on the current tab - * @param code The string of code to execute on the current tab - */ -function executeScript(position: number): void { - // Query for the active tab in the current window - browser.tabs - .query({ active: true, currentWindow: true }) - .then((tabs: Tabs.Tab[]) => { - // Pulls current tab from browser.tabs.query response - const currentTab: Tabs.Tab | number = tabs[0]; - - // Short circuits function execution is current tab isn't found - if (!currentTab) { - return; - } - const currentTabId: number = currentTab.id as number; - - // Executes the script in the current tab - browser.scripting - .executeScript({ - target: { - tabId: currentTabId, - }, - func: scrollWindow, - args: [position], - }) - .then(() => { - console.log("Done Scrolling"); - }); - }); -} - -// // // // - -export function Popup() { - // Sends the `popupMounted` event - React.useEffect(() => { - browser.runtime.sendMessage({ popupMounted: true }); - }, []); - - // Renders the component tree return ( -
-
- -
- { - executeScript(scrollToTopPosition); - }} - onClickScrollBottom={() => { - executeScript(scrollToBottomPosition); - }} - /> -
+
+

+ VOIM TTS +

+