aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/home-assistant/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/home-assistant/webview.js')
-rw-r--r--recipes/home-assistant/webview.js12
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 @@
1module.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};