aboutsummaryrefslogtreecommitdiff
path: root/ext/fg/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/fg/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) {