Skip to content

Commit cadc83a

Browse files
committed
fix: avoid conflicts of same classname on some websites
1 parent 699d36a commit cadc83a

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

src/components/ConversationCard/index.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function ConversationCard(props) {
197197
onClick={() => {
198198
const position = { x: window.innerWidth / 2 - 300, y: window.innerHeight / 2 - 200 }
199199
const toolbarContainer = createElementAtPosition(position.x, position.y)
200-
toolbarContainer.className = 'toolbar-container-not-queryable'
200+
toolbarContainer.className = 'chatgptbox-toolbar-container-not-queryable'
201201
render(
202202
<FloatingToolbar
203203
session={session}

src/components/DecisionCard/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function DecisionCard(props) {
3939

4040
const container = props.container
4141
const siteConfig = props.siteConfig
42-
container.classList.remove('sidebar-free')
42+
container.classList.remove('chatgptbox-sidebar-free')
4343

4444
if (config.appendQuery) {
4545
const appendContainer = getPossibleElementByQuerySelector([config.appendQuery])
@@ -71,7 +71,7 @@ function DecisionCard(props) {
7171
} else {
7272
const appendContainer = getPossibleElementByQuerySelector(siteConfig.appendContainerQuery)
7373
if (appendContainer) {
74-
container.classList.add('sidebar-free')
74+
container.classList.add('chatgptbox-sidebar-free')
7575
appendContainer.appendChild(container)
7676
} else {
7777
const resultsContainerQuery = getPossibleElementByQuerySelector(

src/components/FloatingToolbar/index.jsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@ function FloatingToolbar(props) {
8484
onStop={dragEvent.onStop}
8585
position={virtualPosition}
8686
>
87-
<div className="gpt-selection-window" style={{ width: windowSize[0] * 0.4 + 'px' }}>
88-
<div className="chat-gpt-container">
87+
<div
88+
className="chatgptbox-selection-window"
89+
style={{ width: windowSize[0] * 0.4 + 'px' }}
90+
>
91+
<div className="chatgptbox-container">
8992
<ConversationCard
9093
session={props.session}
9194
question={prompt}
@@ -112,7 +115,7 @@ function FloatingToolbar(props) {
112115
tools.push(
113116
cloneElement(toolConfig.icon, {
114117
size: 20,
115-
className: 'gpt-selection-toolbar-button',
118+
className: 'chatgptbox-selection-toolbar-button',
116119
title: toolConfig.label,
117120
onClick: async () => {
118121
setPrompt(await toolConfig.genPrompt(selection))
@@ -125,7 +128,7 @@ function FloatingToolbar(props) {
125128

126129
return (
127130
<div data-theme={config.themeMode}>
128-
<div className="gpt-selection-toolbar">
131+
<div className="chatgptbox-selection-toolbar">
129132
<img src={logo} width="24" height="24" style="user-select:none;" />
130133
{tools}
131134
</div>

src/content-script/index.jsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async function mountComponent(siteConfig, userConfig) {
2828
)
2929
return
3030

31-
document.querySelectorAll('.chat-gpt-container').forEach((e) => {
31+
document.querySelectorAll('.chatgptbox-container').forEach((e) => {
3232
unmountComponentAtNode(e)
3333
e.remove()
3434
})
@@ -37,12 +37,12 @@ async function mountComponent(siteConfig, userConfig) {
3737
if (userConfig.inputQuery) question = await getInput([userConfig.inputQuery])
3838
if (!question && siteConfig) question = await getInput(siteConfig.inputQuery)
3939

40-
document.querySelectorAll('.chat-gpt-container').forEach((e) => {
40+
document.querySelectorAll('.chatgptbox-container').forEach((e) => {
4141
unmountComponentAtNode(e)
4242
e.remove()
4343
})
4444
const container = document.createElement('div')
45-
container.className = 'chat-gpt-container'
45+
container.className = 'chatgptbox-container'
4646
render(
4747
<DecisionCard
4848
session={initSession()}
@@ -107,7 +107,7 @@ async function prepareForSelectionTools() {
107107
if (selection) {
108108
const position = { x: e.clientX + 15, y: e.clientY - 15 }
109109
toolbarContainer = createElementAtPosition(position.x, position.y)
110-
toolbarContainer.className = 'toolbar-container'
110+
toolbarContainer.className = 'chatgptbox-toolbar-container'
111111
render(
112112
<FloatingToolbar
113113
session={initSession()}
@@ -123,7 +123,7 @@ async function prepareForSelectionTools() {
123123
document.addEventListener('mousedown', (e) => {
124124
if (toolbarContainer && toolbarContainer.contains(e.target)) return
125125

126-
document.querySelectorAll('.toolbar-container').forEach((e) => e.remove())
126+
document.querySelectorAll('.chatgptbox-toolbar-container').forEach((e) => e.remove())
127127
})
128128
document.addEventListener('keydown', (e) => {
129129
if (
@@ -157,7 +157,7 @@ async function prepareForSelectionToolsTouch() {
157157
y: e.changedTouches[0].clientY - 15,
158158
}
159159
toolbarContainer = createElementAtPosition(position.x, position.y)
160-
toolbarContainer.className = 'toolbar-container'
160+
toolbarContainer.className = 'chatgptbox-toolbar-container'
161161
render(
162162
<FloatingToolbar
163163
session={initSession()}
@@ -173,7 +173,7 @@ async function prepareForSelectionToolsTouch() {
173173
document.addEventListener('touchstart', (e) => {
174174
if (toolbarContainer && toolbarContainer.contains(e.target)) return
175175

176-
document.querySelectorAll('.toolbar-container').forEach((e) => e.remove())
176+
document.querySelectorAll('.chatgptbox-toolbar-container').forEach((e) => e.remove())
177177
})
178178
}
179179

@@ -191,7 +191,7 @@ async function prepareForRightClickMenu() {
191191
if (data.itemId === 'new') {
192192
const position = { x: menuX, y: menuY }
193193
const container = createElementAtPosition(position.x, position.y)
194-
container.className = 'toolbar-container-not-queryable'
194+
container.className = 'chatgptbox-toolbar-container-not-queryable'
195195
render(
196196
<FloatingToolbar
197197
session={initSession()}
@@ -207,7 +207,7 @@ async function prepareForRightClickMenu() {
207207
} else {
208208
const position = { x: menuX, y: menuY }
209209
const container = createElementAtPosition(position.x, position.y)
210-
container.className = 'toolbar-container-not-queryable'
210+
container.className = 'chatgptbox-toolbar-container-not-queryable'
211211
render(
212212
<FloatingToolbar
213213
session={initSession()}

src/content-script/styles.scss

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
--dragbar-color: #ccced0;
3737
}
3838

39-
.sidebar-free {
39+
.chatgptbox-sidebar-free {
4040
margin-left: 60px;
4141
}
4242

43-
.chat-gpt-container {
43+
.chatgptbox-container {
4444
width: 100%;
4545
flex-basis: 0;
4646
flex-grow: 1;
@@ -101,7 +101,7 @@
101101

102102
.gpt-loading {
103103
color: var(--font-color);
104-
animation: gpt-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
104+
animation: chatgptbox-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
105105
}
106106

107107
.code-copy-btn {
@@ -202,7 +202,7 @@
202202
}
203203
}
204204

205-
@keyframes gpt-pulse {
205+
@keyframes chatgptbox-pulse {
206206
0%,
207207
100% {
208208
opacity: 1;
@@ -213,7 +213,7 @@
213213
}
214214
}
215215

216-
.gpt-selection-toolbar {
216+
.chatgptbox-selection-toolbar {
217217
display: flex;
218218
align-items: center;
219219
border-radius: 15px;
@@ -222,7 +222,7 @@
222222
box-shadow: 4px 2px 4px rgba(0, 0, 0, 0.2);
223223
}
224224

225-
.gpt-selection-toolbar-button {
225+
.chatgptbox-selection-toolbar-button {
226226
margin-left: 2px;
227227
padding: 2px;
228228
border-radius: 30px;
@@ -231,11 +231,11 @@
231231
cursor: pointer;
232232
}
233233

234-
.gpt-selection-toolbar-button:hover {
234+
.chatgptbox-selection-toolbar-button:hover {
235235
background-color: #d4d5da;
236236
}
237237

238-
.gpt-selection-window {
238+
.chatgptbox-selection-window {
239239
height: auto;
240240
border-radius: 8px;
241241
background-color: var(--theme-color);

0 commit comments

Comments
 (0)