Skip to content

Commit

Permalink
fix(export-element): print error when target element not found
Browse files Browse the repository at this point in the history
  • Loading branch information
iamogbz committed Dec 19, 2024
1 parent 05c0d65 commit f03f21c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion scripts/export-element/index.user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
});

const params: {
eventTarget: EventTarget | null;
target: Node | null;
type: (typeof Types)[keyof typeof Types];
} = {
eventTarget: null,
target: null,
type: Types.PDF,
};
Expand Down Expand Up @@ -40,6 +42,8 @@

// Add context menu to user script
document.addEventListener("contextmenu", function (event) {
params.eventTarget = event.target;

const selectedText =
window.getSelection?.()?.toString() ??
document.getSelection?.()?.toString() ??
Expand Down Expand Up @@ -182,7 +186,7 @@
}
}
} else {
alert("Node not found!");
console.error("Node not found!", params.eventTarget);
}
}

Expand Down

0 comments on commit f03f21c

Please sign in to comment.