diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-08-12 12:55:37 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-08-12 12:55:37 +0900 |
commit | 8e5ceebf61088727fdca524d062162fbdfc86155 (patch) | |
tree | 90fb9ed24018ecf204a791a35ad4cc572bb81bb0 /src/background/index.js | |
parent | f1d4bb8c3790d30b4db112b2c185054c119d36b5 (diff) |
implement simple tab switch
Diffstat (limited to 'src/background/index.js')
-rw-r--r-- | src/background/index.js | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/background/index.js b/src/background/index.js index ee02f63..d4e0098 100644 --- a/src/background/index.js +++ b/src/background/index.js @@ -1,4 +1,18 @@ +import * as tabs from './tabs'; + +const KEY_MAP = { + 'tabs.prev': 104, + 'tabs.next': 108 +}; + browser.runtime.onMessage.addListener((request, sender, sendResponse) => { - console.log("Pressed " + request.which); - sendResponse({ response: "Response from background script" }); + switch (request.key) { + case KEY_MAP['tabs.prev']: + tabs.selectPrevTab(sender.tab.index); + break; + case KEY_MAP['tabs.next']: + tabs.selectNextTab(sender.tab.index); + break; + } + sendResponse(); }); |