diff options
author | 2022-02-16 08:37:26 -0300 | |
---|---|---|
committer | 2022-02-16 12:37:26 +0100 | |
commit | 7e4f479b888e9c47faf074962140eb66803a557b (patch) | |
tree | 3912c4e54a04d6c5ed6f498b0a67ef9aeba961db /recipes/feedly/webview.js | |
parent | docs: add brunoccr as a contributor for code (#835) (diff) | |
download | ferdium-recipes-7e4f479b888e9c47faf074962140eb66803a557b.tar.gz ferdium-recipes-7e4f479b888e9c47faf074962140eb66803a557b.tar.zst ferdium-recipes-7e4f479b888e9c47faf074962140eb66803a557b.zip |
Fix Feedly counter script when no pending article to read (#826)
Co-authored-by: Bruno Rossetto <bruno.rossetto@sottelli.com>
Diffstat (limited to 'recipes/feedly/webview.js')
-rw-r--r-- | recipes/feedly/webview.js | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/recipes/feedly/webview.js b/recipes/feedly/webview.js index 3e15fd5..c1108ff 100644 --- a/recipes/feedly/webview.js +++ b/recipes/feedly/webview.js | |||
@@ -2,11 +2,14 @@ module.exports = Ferdi => { | |||
2 | const getMessages = () => { | 2 | const getMessages = () => { |
3 | const newsDOM = document.querySelectorAll( | 3 | const newsDOM = document.querySelectorAll( |
4 | "div[title='All'] > .LeftnavListRow__count", | 4 | "div[title='All'] > .LeftnavListRow__count", |
5 | )[0].textContent; | 5 | ); |
6 | let counter = Ferdi.safeParseInt(newsDOM); | ||
7 | 6 | ||
8 | if (newsDOM && (newsDOM.includes('K') || newsDOM.includes('+'))) { | 7 | let counter = 0; |
9 | counter = `${newsDOM.slice(0, Math.max(0, newsDOM.indexOf('K')))}000`; | 8 | |
9 | if (newsDOM && newsDOM.length > 0) { | ||
10 | const textContent = newsDOM[0].textContent; | ||
11 | |||
12 | counter = textContent.includes('K') || textContent.includes('+') ? `${textContent.slice(0, Math.max(0, textContent.indexOf('K')))}000` : Ferdi.safeParseInt(textContent); | ||
10 | } | 13 | } |
11 | 14 | ||
12 | Ferdi.setBadge(counter); | 15 | Ferdi.setBadge(counter); |