aboutsummaryrefslogtreecommitdiff
path: root/ext/bg
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-09-28 20:14:21 -0700
committerAlex Yatskov <alex@foosoft.net>2016-09-28 20:14:21 -0700
commit004a0d5281fb1793f9106de06fc6758ff97a48fb (patch)
tree95e6c50e7e83c800341f4878475c180cfb4756f2 /ext/bg
parent071902cd057e4828afbc7082271dba1d3ccc1762 (diff)
Fix activation bug
Diffstat (limited to 'ext/bg')
-rw-r--r--ext/bg/js/yomichan.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/bg/js/yomichan.js b/ext/bg/js/yomichan.js
index f1b3ffc4..46a240a3 100644
--- a/ext/bg/js/yomichan.js
+++ b/ext/bg/js/yomichan.js
@@ -23,6 +23,7 @@ class Yomichan {
Handlebars.registerHelper('kanjiLinks', kanjiLinks);
this.translator = new Translator();
+ this.options = null;
this.importTabId = null;
this.asyncPools = {};
this.ankiConnectVer = 0;
@@ -30,8 +31,6 @@ class Yomichan {
chrome.runtime.onMessage.addListener(this.onMessage.bind(this));
chrome.browserAction.onClicked.addListener(this.onBrowserAction.bind(this));
- chrome.tabs.onCreated.addListener(tab => this.onTabReady(tab.id));
- chrome.tabs.onUpdated.addListener(this.onTabReady.bind(this));
loadOptions().then(opts => {
this.setOptions(opts);
@@ -66,11 +65,6 @@ class Yomichan {
return true;
}
- onTabReady(tabId) {
- this.tabInvoke(tabId, 'setOptions', this.options);
- this.tabInvoke(tabId, 'setEnabled', this.state === 'enabled');
- }
-
onBrowserAction() {
switch (this.state) {
case 'disabled':
@@ -258,6 +252,14 @@ class Yomichan {
return note;
}
+ api_getEnabled({callback}) {
+ callback(this.state === 'enabled');
+ }
+
+ api_getOptions({callback}) {
+ loadOptions().then(opts => callback(opts));
+ }
+
api_addDefinition({definition, mode, callback}) {
const note = this.formatNote(definition, mode);
this.ankiInvokeSafe('addNote', {note}, null, callback);