From 681f58e3beea4e639a9f22ba101af427d7a76370 Mon Sep 17 00:00:00 2001 From: Alexandre <32882826+Mralexandresys@users.noreply.github.com> Date: Sun, 26 Nov 2023 02:34:38 +0100 Subject: [PATCH] fix badge for Instagram (#468) --- recipes/instagram-direct-messages/package.json | 2 +- recipes/instagram-direct-messages/webview.js | 6 ++++-- recipes/instagram/package.json | 2 +- recipes/instagram/webview.js | 12 ++++++------ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/recipes/instagram-direct-messages/package.json b/recipes/instagram-direct-messages/package.json index 41aa129f4..ab94fae76 100644 --- a/recipes/instagram-direct-messages/package.json +++ b/recipes/instagram-direct-messages/package.json @@ -1,7 +1,7 @@ { "id": "instagram-direct-messages", "name": "Instagram Direct Messages", - "version": "1.1.1", + "version": "1.1.2", "license": "MIT", "config": { "serviceURL": "https://www.instagram.com/direct/inbox/", diff --git a/recipes/instagram-direct-messages/webview.js b/recipes/instagram-direct-messages/webview.js index 01187b812..eb33ed1b3 100644 --- a/recipes/instagram-direct-messages/webview.js +++ b/recipes/instagram-direct-messages/webview.js @@ -12,9 +12,11 @@ setInterval(() => { module.exports = Ferdium => { const getMessages = () => { - const element = document.querySelector('a[href^="/direct/inbox"]'); + const element = document.querySelector('a[href^="/direct/inbox"] span'); Ferdium.setBadge( - element.textContent ? Ferdium.safeParseInt(element.textContent) : 0, + element && element.textContent + ? Ferdium.safeParseInt(element.textContent) + : 0, ); }; diff --git a/recipes/instagram/package.json b/recipes/instagram/package.json index e0449bb7c..742516424 100644 --- a/recipes/instagram/package.json +++ b/recipes/instagram/package.json @@ -1,7 +1,7 @@ { "id": "instagram", "name": "Instagram", - "version": "2.5.2", + "version": "2.5.3", "license": "MIT", "config": { "serviceURL": "https://instagram.com/", diff --git a/recipes/instagram/webview.js b/recipes/instagram/webview.js index b63e68350..3092d2191 100644 --- a/recipes/instagram/webview.js +++ b/recipes/instagram/webview.js @@ -40,12 +40,12 @@ module.exports = (Ferdium, settings) => { ); const getMessages = () => { - const element = document.querySelector('a[href^="/direct/inbox"]'); - if (element) { - Ferdium.setBadge( - element.textContent ? Ferdium.safeParseInt(element.textContent) : 0, - ); - } + const element = document.querySelector('a[href^="/direct/inbox"] span'); + Ferdium.setBadge( + element && element.textContent + ? Ferdium.safeParseInt(element.textContent) + : 0, + ); }; Ferdium.loop(getMessages);