diff options
-rw-r--r-- | recipes/slite/webview.js | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/recipes/slite/webview.js b/recipes/slite/webview.js index 6e0fa46..1d6957a 100644 --- a/recipes/slite/webview.js +++ b/recipes/slite/webview.js | |||
@@ -1,22 +1,16 @@ | |||
1 | "use strict"; | 1 | "use strict"; |
2 | 2 | ||
3 | var _path = _interopRequireDefault(require("path")); | 3 | let getInnerInt = selector => { |
4 | 4 | const element = document.querySelector(selector); | |
5 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 5 | return element && parseInt(element.innerText); |
6 | } | ||
6 | 7 | ||
7 | module.exports = Ferdi => { | 8 | module.exports = Ferdi => { |
8 | const getMessages = function getMessages() { | 9 | const getMessages = function getMessages() { |
9 | let direct = 0; | 10 | let direct = ( |
10 | 11 | getInnerInt("#app button[data-test-id='notificationsCount']") || 0 | |
11 | const notificationButton = document.querySelector( | ||
12 | "#app button[data-test-id='notificationsCount'" | ||
13 | ); | 12 | ); |
14 | 13 | ||
15 | if (notificationButton) { | ||
16 | const notificationCount = parseInt(notificationButton.innerText); | ||
17 | direct = isNaN(notificationCount) ? 0 : notificationCount; | ||
18 | } | ||
19 | |||
20 | Ferdi.setBadge(direct); | 14 | Ferdi.setBadge(direct); |
21 | }; | 15 | }; |
22 | 16 | ||