diff options
Diffstat (limited to 'recipes/instagram')
-rw-r--r-- | recipes/instagram/package.json | 2 | ||||
-rw-r--r-- | recipes/instagram/webview.js | 33 |
2 files changed, 27 insertions, 8 deletions
diff --git a/recipes/instagram/package.json b/recipes/instagram/package.json index 820872c..4b8f7ac 100644 --- a/recipes/instagram/package.json +++ b/recipes/instagram/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "instagram", | 2 | "id": "instagram", |
3 | "name": "Instagram", | 3 | "name": "Instagram", |
4 | "version": "2.4.0", | 4 | "version": "2.4.1", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://instagram.com/direct/inbox", | 7 | "serviceURL": "https://instagram.com/direct/inbox", |
diff --git a/recipes/instagram/webview.js b/recipes/instagram/webview.js index 66d89e6..e363ad3 100644 --- a/recipes/instagram/webview.js +++ b/recipes/instagram/webview.js | |||
@@ -14,16 +14,35 @@ module.exports = Ferdium => { | |||
14 | 14 | ||
15 | // https://github.com/ferdium/ferdium-recipes/blob/9d715597a600710c20f75412d3dcd8cdb7b3c39e/docs/frontend_api.md#usage-4 | 15 | // https://github.com/ferdium/ferdium-recipes/blob/9d715597a600710c20f75412d3dcd8cdb7b3c39e/docs/frontend_api.md#usage-4 |
16 | // Helper that activates DarkReader and injects your darkmode.css at the same time | 16 | // Helper that activates DarkReader and injects your darkmode.css at the same time |
17 | Ferdium.handleDarkMode((isEnabled, helpers) => { | 17 | Ferdium.handleDarkMode((isEnabled) => { |
18 | |||
19 | var url = new URL(window.location.href); | ||
20 | var searchParams = url.searchParams; | ||
21 | var isDarkModeParam = searchParams.get('theme'); | ||
22 | var changedParams = false; | ||
23 | |||
18 | if (isEnabled) { | 24 | if (isEnabled) { |
19 | helpers.enableDarkMode(); | 25 | isDarkModeParam ? null : |
20 | if (!helpers.isDarkModeStyleInjected()) { | 26 | ( |
21 | helpers.injectDarkModeStyle(); | 27 | searchParams.set('theme', 'dark'), |
22 | } | 28 | changedParams = true |
29 | ); | ||
23 | } else { | 30 | } else { |
24 | helpers.disableDarkMode(); | 31 | isDarkModeParam ? |
25 | helpers.removeDarkModeStyle(); | 32 | ( |
33 | searchParams.delete('theme', 'dark'), | ||
34 | changedParams = true | ||
35 | ) | ||
36 | : null; | ||
26 | } | 37 | } |
38 | |||
39 | changedParams ? | ||
40 | ( | ||
41 | url.search = searchParams.toString(), | ||
42 | window.location.href = url.toString() | ||
43 | ) | ||
44 | : null; | ||
45 | |||
27 | }); | 46 | }); |
28 | 47 | ||
29 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | 48 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); |