summaryrefslogtreecommitdiff
path: root/source/features/selection-in-new-tab.tsx
diff options
context:
space:
mode:
authorGravatar yakov116 <16872793+yakov116@users.noreply.github.com> 2020-06-26 04:30:43 -0400
committerGravatar GitHub <noreply@github.com> 2020-06-26 10:30:43 +0200
commitc6c727ca571c91d1ff426e218ccadb075cdb2af6 (patch)
treee1855bb6c6d37f0b28b97be73192316fec2067e5 /source/features/selection-in-new-tab.tsx
parent15da229b3a29483f076782361ac429854f18e18b (diff)
downloadrefined-github-c6c727ca571c91d1ff426e218ccadb075cdb2af6.tar.gz
refined-github-c6c727ca571c91d1ff426e218ccadb075cdb2af6.tar.zst
refined-github-c6c727ca571c91d1ff426e218ccadb075cdb2af6.zip
Lint and avoid errors (#3256)
Diffstat (limited to 'source/features/selection-in-new-tab.tsx')
-rw-r--r--source/features/selection-in-new-tab.tsx24
1 files changed, 13 insertions, 11 deletions
diff --git a/source/features/selection-in-new-tab.tsx b/source/features/selection-in-new-tab.tsx
index 6ef6c2c1..59da6402 100644
--- a/source/features/selection-in-new-tab.tsx
+++ b/source/features/selection-in-new-tab.tsx
@@ -3,18 +3,20 @@ import select from 'select-dom';
import features from '.';
import {isEditable} from '../helpers/dom-utils';
-function init(): void {
- document.addEventListener('keypress', (event: KeyboardEvent) => {
- const selected = select<HTMLAnchorElement>('.navigation-focus .js-navigation-open[href]');
- if (selected && event.key === 'O' && !isEditable(event.target)) {
- void browser.runtime.sendMessage({
- openUrls: [selected.href]
- });
+function openInNewTab({key, target}: KeyboardEvent): void {
+ const selected = select<HTMLAnchorElement>('.navigation-focus .js-navigation-open[href]');
+ if (selected && key === 'O' && !isEditable(target)) {
+ void browser.runtime.sendMessage({
+ openUrls: [selected.href]
+ });
- // Get the list element that contains the unread class and mark it as read.
- selected.closest('.unread')?.classList.replace('unread', 'read');
- }
- });
+ // Get the list element that contains the unread class and mark it as read.
+ selected.closest('.unread')?.classList.replace('unread', 'read');
+ }
+}
+
+function init(): void {
+ document.addEventListener('keypress', openInNewTab);
}
void features.add({