From df0bf5e22285905dfc96e4d3968c9f61e879a6ea Mon Sep 17 00:00:00 2001 From: josc146 Date: Tue, 28 Mar 2023 15:15:24 +0800 Subject: [PATCH] fix: prevent accidental appearance of floating selectionTools on certain websites --- src/content-script/index.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/content-script/index.jsx b/src/content-script/index.jsx index ed6cd14..4204611 100644 --- a/src/content-script/index.jsx +++ b/src/content-script/index.jsx @@ -126,7 +126,11 @@ async function prepareForSelectionTools() { deleteToolbar() setTimeout(() => { - const selection = window.getSelection()?.toString().trim() + const selection = window + .getSelection() + ?.toString() + .trim() + .replace(/^-+|-+$/g, '') if (selection) { const inputElement = selectionElement.querySelector('input, textarea') let position @@ -183,7 +187,11 @@ async function prepareForSelectionToolsTouch() { deleteToolbar() setTimeout(() => { - const selection = window.getSelection()?.toString().trim() + const selection = window + .getSelection() + ?.toString() + .trim() + .replace(/^-+|-+$/g, '') if (selection) { toolbarContainer = createElementAtPosition( e.changedTouches[0].pageX + 20,