aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar André Oliveira <37463445+SpecialAro@users.noreply.github.com>2022-06-10 03:46:56 +0530
committerLibravatar Vijay A <vraravam@users.noreply.github.com>2022-06-10 03:46:56 +0530
commitab43f4b01a3bd62ff068ad5e09e0f0b2a2069f30 (patch)
treea3cf42ebcddcb89b416429ce2ccde55e36f2de2b
parentAdd webview.js to some services that were generated without it. (#42) (diff)
downloadferdium-recipes-ab43f4b01a3bd62ff068ad5e09e0f0b2a2069f30.tar.gz
ferdium-recipes-ab43f4b01a3bd62ff068ad5e09e0f0b2a2069f30.tar.zst
ferdium-recipes-ab43f4b01a3bd62ff068ad5e09e0f0b2a2069f30.zip
Add the native dark mode theme for Instagram (#44)
-rw-r--r--recipes/instagram/package.json2
-rw-r--r--recipes/instagram/webview.js33
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'));