Before adding any markers to local HTML ensure we dont have any already

This commit is contained in:
Jackson Harper
2022-11-21 15:52:57 +08:00
committed by Hongbo Wu
parent 39b0cbd453
commit 64e2bb39b6

View File

@ -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) {