From 8793fa5fde58161e245e05bcfeaa41f74db79590 Mon Sep 17 00:00:00 2001 From: josc146 Date: Sat, 18 Mar 2023 23:54:57 +0800 Subject: [PATCH] fix: avoid conflicts of same classname on some websites --- src/components/ConversationCard/index.jsx | 2 +- src/components/DecisionCard/index.jsx | 4 ++-- src/components/FloatingToolbar/index.jsx | 11 +++++++---- src/content-script/index.jsx | 18 +++++++++--------- src/content-script/styles.scss | 16 ++++++++-------- 5 files changed, 27 insertions(+), 24 deletions(-) diff --git a/src/components/ConversationCard/index.jsx b/src/components/ConversationCard/index.jsx index 013b8c5..cd49e81 100644 --- a/src/components/ConversationCard/index.jsx +++ b/src/components/ConversationCard/index.jsx @@ -197,7 +197,7 @@ function ConversationCard(props) { onClick={() => { const position = { x: window.innerWidth / 2 - 300, y: window.innerHeight / 2 - 200 } const toolbarContainer = createElementAtPosition(position.x, position.y) - toolbarContainer.className = 'toolbar-container-not-queryable' + toolbarContainer.className = 'chatgptbox-toolbar-container-not-queryable' render( -
-
+
+
{ setPrompt(await toolConfig.genPrompt(selection)) @@ -125,7 +128,7 @@ function FloatingToolbar(props) { return (
-
+
{tools}
diff --git a/src/content-script/index.jsx b/src/content-script/index.jsx index 68a4be3..69f6b79 100644 --- a/src/content-script/index.jsx +++ b/src/content-script/index.jsx @@ -28,7 +28,7 @@ async function mountComponent(siteConfig, userConfig) { ) return - document.querySelectorAll('.chat-gpt-container').forEach((e) => { + document.querySelectorAll('.chatgptbox-container').forEach((e) => { unmountComponentAtNode(e) e.remove() }) @@ -37,12 +37,12 @@ async function mountComponent(siteConfig, userConfig) { if (userConfig.inputQuery) question = await getInput([userConfig.inputQuery]) if (!question && siteConfig) question = await getInput(siteConfig.inputQuery) - document.querySelectorAll('.chat-gpt-container').forEach((e) => { + document.querySelectorAll('.chatgptbox-container').forEach((e) => { unmountComponentAtNode(e) e.remove() }) const container = document.createElement('div') - container.className = 'chat-gpt-container' + container.className = 'chatgptbox-container' render( { if (toolbarContainer && toolbarContainer.contains(e.target)) return - document.querySelectorAll('.toolbar-container').forEach((e) => e.remove()) + document.querySelectorAll('.chatgptbox-toolbar-container').forEach((e) => e.remove()) }) document.addEventListener('keydown', (e) => { if ( @@ -157,7 +157,7 @@ async function prepareForSelectionToolsTouch() { y: e.changedTouches[0].clientY - 15, } toolbarContainer = createElementAtPosition(position.x, position.y) - toolbarContainer.className = 'toolbar-container' + toolbarContainer.className = 'chatgptbox-toolbar-container' render( { if (toolbarContainer && toolbarContainer.contains(e.target)) return - document.querySelectorAll('.toolbar-container').forEach((e) => e.remove()) + document.querySelectorAll('.chatgptbox-toolbar-container').forEach((e) => e.remove()) }) } @@ -191,7 +191,7 @@ async function prepareForRightClickMenu() { if (data.itemId === 'new') { const position = { x: menuX, y: menuY } const container = createElementAtPosition(position.x, position.y) - container.className = 'toolbar-container-not-queryable' + container.className = 'chatgptbox-toolbar-container-not-queryable' render(