aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js/popup.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-13 10:50:56 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2019-10-13 12:12:51 -0400
commit118f200500b3a27afc873a896b8304387456e2e7 (patch)
tree783fbb7763fb893575d18619a3bd3951a370e026 /ext/fg/js/popup.js
parent320af99b7676a37157e2d7207756dd502e6be608 (diff)
Simplified how the auto theme works
Diffstat (limited to 'ext/fg/js/popup.js')
-rw-r--r--ext/fg/js/popup.js19
1 files changed, 8 insertions, 11 deletions
diff --git a/ext/fg/js/popup.js b/ext/fg/js/popup.js
index ef4cdb67..880e3efe 100644
--- a/ext/fg/js/popup.js
+++ b/ext/fg/js/popup.js
@@ -271,19 +271,16 @@ class Popup {
}
updateTheme() {
- this.container.dataset.yomichanTheme = this.getTheme(this.options.general.popupOuterTheme);
+ this.container.dataset.yomichanTheme = this.options.general.popupOuterTheme;
+ this.container.dataset.yomichanSiteColor = this.getSiteColor();
}
- getTheme(themeName) {
- if (themeName === 'auto') {
- const color = [255, 255, 255];
- Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.documentElement).backgroundColor));
- Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.body).backgroundColor));
- const dark = (color[0] < 128 && color[1] < 128 && color[2] < 128);
- themeName = dark ? 'dark' : 'default';
- }
-
- return themeName;
+ getSiteColor() {
+ const color = [255, 255, 255];
+ Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.documentElement).backgroundColor));
+ Popup.addColor(color, Popup.getColorInfo(window.getComputedStyle(document.body).backgroundColor));
+ const dark = (color[0] < 128 && color[1] < 128 && color[2] < 128);
+ return dark ? 'dark' : 'light';
}
static addColor(target, color) {