diff options
author | Stefan Malzner <stefan@adlk.io> | 2018-12-07 22:39:12 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2018-12-07 22:39:12 +0100 |
commit | 65aaac06beac7f070a3a81adeffb8e1887d9f12b (patch) | |
tree | e2b4f452eef8c17198845e7a59c49b4fe28b1823 /src/webview/darkmode.js | |
parent | feat(Service): Add option to change spellchecking language by service (diff) | |
download | ferdium-app-65aaac06beac7f070a3a81adeffb8e1887d9f12b.tar.gz ferdium-app-65aaac06beac7f070a3a81adeffb8e1887d9f12b.tar.zst ferdium-app-65aaac06beac7f070a3a81adeffb8e1887d9f12b.zip |
chore(Recipe): Refactor recipe plugin
Diffstat (limited to 'src/webview/darkmode.js')
-rw-r--r-- | src/webview/darkmode.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/webview/darkmode.js b/src/webview/darkmode.js index 9830ef33c..73c7007c6 100644 --- a/src/webview/darkmode.js +++ b/src/webview/darkmode.js | |||
@@ -1,7 +1,13 @@ | |||
1 | /* eslint no-bitwise: ["error", { "int32Hint": true }] */ | ||
2 | |||
1 | import path from 'path'; | 3 | import path from 'path'; |
2 | import fs from 'fs-extra'; | 4 | import fs from 'fs-extra'; |
3 | 5 | ||
4 | const ID = 'franz-theme-dark-mode'; | 6 | const debug = require('debug')('Franz:DarkMode'); |
7 | |||
8 | const chars = [...'abcdefghijklmnopqrstuvwxyz']; | ||
9 | |||
10 | const ID = [...Array(20)].map(() => chars[Math.random() * chars.length | 0]).join``; | ||
5 | 11 | ||
6 | export function injectDarkModeStyle(recipePath) { | 12 | export function injectDarkModeStyle(recipePath) { |
7 | const darkModeStyle = path.join(recipePath, 'darkmode.css'); | 13 | const darkModeStyle = path.join(recipePath, 'darkmode.css'); |
@@ -12,6 +18,8 @@ export function injectDarkModeStyle(recipePath) { | |||
12 | styles.innerHTML = data.toString(); | 18 | styles.innerHTML = data.toString(); |
13 | 19 | ||
14 | document.querySelector('head').appendChild(styles); | 20 | document.querySelector('head').appendChild(styles); |
21 | |||
22 | debug('Injected Dark Mode style with ID', ID); | ||
15 | } | 23 | } |
16 | } | 24 | } |
17 | 25 | ||
@@ -20,6 +28,8 @@ export function removeDarkModeStyle() { | |||
20 | 28 | ||
21 | if (style) { | 29 | if (style) { |
22 | style.remove(); | 30 | style.remove(); |
31 | |||
32 | debug('Removed Dark Mode Style with ID', ID); | ||
23 | } | 33 | } |
24 | } | 34 | } |
25 | 35 | ||