diff options
author | 2022-06-07 13:59:08 +0200 | |
---|---|---|
committer | 2022-06-07 12:59:08 +0100 | |
commit | 256254e15e1bcd642054b90d25463707688ff52c (patch) | |
tree | 8b8988fcfbf8db636d11f50433889028cb8b4537 /recipes/home-assistant/webview.js | |
parent | [Whatsapp] Remove max width limit of 1600px (#49) (diff) | |
download | ferdium-recipes-256254e15e1bcd642054b90d25463707688ff52c.tar.gz ferdium-recipes-256254e15e1bcd642054b90d25463707688ff52c.tar.zst ferdium-recipes-256254e15e1bcd642054b90d25463707688ff52c.zip |
Add home assistant recipe (#47)
Diffstat (limited to 'recipes/home-assistant/webview.js')
-rw-r--r-- | recipes/home-assistant/webview.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/recipes/home-assistant/webview.js b/recipes/home-assistant/webview.js new file mode 100644 index 0000000..a449cc4 --- /dev/null +++ b/recipes/home-assistant/webview.js | |||
@@ -0,0 +1,12 @@ | |||
1 | module.exports = Ferdium => { | ||
2 | const getMessages = () => { | ||
3 | const badges = document.querySelector("home-assistant").shadowRoot.querySelector("home-assistant-main").shadowRoot.querySelector("ha-sidebar").shadowRoot.querySelectorAll(".notification-badge"); | ||
4 | if (badges.length > 0) { | ||
5 | var count = Ferdium.safeParseInt(badges[0].textContent.replace(/[^\p{N}]/gu, '')); | ||
6 | Ferdium.setBadge(count) | ||
7 | } else { | ||
8 | Ferdium.setBadge(0) | ||
9 | } | ||
10 | }; | ||
11 | Ferdium.loop(getMessages); | ||
12 | }; | ||