From 64e2bb39b6905e9adbc110967b4b607315677568 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Mon, 21 Nov 2022 15:52:57 +0800 Subject: [PATCH] Before adding any markers to local HTML ensure we dont have any already --- apple/Sources/ShareExtension/ShareExtension.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/apple/Sources/ShareExtension/ShareExtension.js b/apple/Sources/ShareExtension/ShareExtension.js index 6ca9c7287..acff8657f 100644 --- a/apple/Sources/ShareExtension/ShareExtension.js +++ b/apple/Sources/ShareExtension/ShareExtension.js @@ -12,6 +12,19 @@ function iconURL() { ShareExtension.prototype = { markHighlightSelection: () => { + // First remove any previous markers, this would only normally happen during debugging + try { + const markers = window.document.querySelectorAll( + `span[data-omnivore-highlight-start="true"], + span[data-omnivore-highlight-end="true"]` + ) + + for (let i = 0; i < markers.length; i++) { + markers[i].remove(); + } + } catch { + // This should be OK + } try { const sel = window.getSelection(); if (sel.rangeCount) {