From 14fd0d65144bd672bcfb9702fdfb96d0963f350b Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Fri, 3 Jun 2016 21:17:55 -0700 Subject: [PATCH] Option preference page on install. --- ext/bg/js/yomichan.js | 14 ++++++++++---- 1 file 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];