diff --git a/src/content-script/index.jsx b/src/content-script/index.jsx index 0c9be19..25b1030 100644 --- a/src/content-script/index.jsx +++ b/src/content-script/index.jsx @@ -1,4 +1,5 @@ import './styles.scss' +import { unmountComponentAtNode } from 'react-dom' import { render } from 'preact' import DecisionCard from '../components/DecisionCard' import { config as siteConfig } from './site-adapters' @@ -27,13 +28,19 @@ async function mountComponent(siteConfig, userConfig) { ) return - document.querySelectorAll('.chat-gpt-container').forEach((e) => e.remove()) + document.querySelectorAll('.chat-gpt-container').forEach((e) => { + unmountComponentAtNode(e) + e.remove() + }) let question if (userConfig.inputQuery) question = await getInput([userConfig.inputQuery]) if (!question && siteConfig) question = await getInput(siteConfig.inputQuery) - document.querySelectorAll('.chat-gpt-container').forEach((e) => e.remove()) + document.querySelectorAll('.chat-gpt-container').forEach((e) => { + unmountComponentAtNode(e) + e.remove() + }) const container = document.createElement('div') container.className = 'chat-gpt-container' render(