Skip to content

Commit

Permalink
Add keyboard hotkey (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rainyan authored Nov 6, 2023
1 parent a2b2ad4 commit 324e0f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
12 changes: 11 additions & 1 deletion jump_to_audio_tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function errorLog() {
console.error(arguments);
}

browser.browserAction.onClicked.addListener((tab, info) => {
function jumpToLatestAudibleTab() {
let targetTabs = AUDIBLE_TABS.sort((a, b) => b.lastAccessed - a.lastAccessed);
if (targetTabs.length === 0) {
return;
Expand Down Expand Up @@ -47,6 +47,16 @@ browser.browserAction.onClicked.addListener((tab, info) => {
});
});
});
}

browser.commands.onCommand.addListener((command) => {
if (command === "jump-to-latest-audible-tab") {
jumpToLatestAudibleTab();
}
});

browser.browserAction.onClicked.addListener((tab, info) => {
jumpToLatestAudibleTab();
});

browser.contextMenus.onClicked.addListener((info, tab) => {
Expand Down
8 changes: 8 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,13 @@
"32": "icons/Volume_Mute.svg",
"64": "icons/Volume_Mute.svg"
}
},
"commands": {
"jump-to-latest-audible-tab": {
"suggested_key": {
"default": "Alt+J"
},
"description": "Jump to latest audible tab"
}
}
}

0 comments on commit 324e0f3

Please sign in to comment.