aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/yomichan.js
diff options
context:
space:
mode:
authorAlex Yatskov <alex@foosoft.net>2016-03-27 17:04:49 -0700
committerAlex Yatskov <alex@foosoft.net>2016-03-27 17:04:49 -0700
commit43d14c0c81824d71cda16c9921348719844044af (patch)
tree91cffa6faf971efbeaf6efab6a5995b251de961d /ext/bg/yomichan.js
parent4b35a6c5563ca7a0d050c049280aafeb097060c0 (diff)
Updates
Diffstat (limited to 'ext/bg/yomichan.js')
-rw-r--r--ext/bg/yomichan.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/ext/bg/yomichan.js b/ext/bg/yomichan.js
index 971e739c..9a049f77 100644
--- a/ext/bg/yomichan.js
+++ b/ext/bg/yomichan.js
@@ -53,7 +53,6 @@ class Yomichan {
switch (this.state) {
case 'disabled':
this.updateState('loading');
- this.translator.loadData(this.res, () => this.updateState('enabled'));
break;
case 'enabled':
this.updateState('disabled');
@@ -62,9 +61,26 @@ class Yomichan {
}
updateState(state) {
- const text = {'disabled': '', 'enabled': 'on', 'loading': '...'}[state];
- chrome.browserAction.setBadgeText({text: text});
this.state = state;
+
+ switch (state) {
+ case 'disabled':
+ chrome.browserAction.setBadgeText({text: ''});
+ break;
+ case 'enabled':
+ chrome.browserAction.setBadgeText({text: 'on'});
+ break;
+ case 'loading':
+ chrome.browserAction.setBadgeText({text: '...'});
+ this.translator.loadData(this.res, () => this.updateState('enabled'));
+ break;
+ }
+
+ chrome.tabs.query({}, (tabs) => {
+ for (const tab of tabs) {
+ chrome.tabs.sendMessage(tab.id, this.state, () => null);
+ }
+ });
}
}