Skip to content

Commit 6cee31c

Browse files
committed
fix: prevent accidental appearance of floating selectionTools on certain websites
1 parent 42971dc commit 6cee31c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/content-script/index.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ async function prepareForSelectionTools() {
126126

127127
deleteToolbar()
128128
setTimeout(() => {
129-
const selection = window.getSelection()?.toString().trim()
129+
const selection = window
130+
.getSelection()
131+
?.toString()
132+
.trim()
133+
.replace(/^-+|-+$/g, '')
130134
if (selection) {
131135
const inputElement = selectionElement.querySelector('input, textarea')
132136
let position
@@ -183,7 +187,11 @@ async function prepareForSelectionToolsTouch() {
183187

184188
deleteToolbar()
185189
setTimeout(() => {
186-
const selection = window.getSelection()?.toString().trim()
190+
const selection = window
191+
.getSelection()
192+
?.toString()
193+
.trim()
194+
.replace(/^-+|-+$/g, '')
187195
if (selection) {
188196
toolbarContainer = createElementAtPosition(
189197
e.changedTouches[0].pageX + 20,

0 commit comments

Comments
 (0)