diff options
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/yomichan.js | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js index 4120dd2b..2c13e8c7 100644 --- a/ext/bg/js/yomichan.js +++ b/ext/bg/js/yomichan.js @@ -37,18 +37,24 @@ class Yomichan { this.asyncPools = {}; this.setState('disabled'); + chrome.runtime.onInstalled.addListener(this.onInstalled.bind(this)); + chrome.runtime.onMessage.addListener(this.onMessage.bind(this)); + chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this)); + loadOptions((opts) => { this.setOptions(opts); - - chrome.runtime.onMessage.addListener(this.onMessage.bind(this)); - chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this)); - if (this.options.activateOnStartup) { this.setState('loading'); } }); } + onInstalled(details) { + if (details.reason === 'install') { + chrome.runtime.openOptionsPage(); + } + } + onMessage(request, sender, callback) { const {action, params} = request, method = this['api_' + action]; |