diff options
author | Francisco Marques <franciscopcmarques@gmail.com> | 2020-10-10 03:39:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-10 03:39:48 +0100 |
commit | 562ffde69b858b9584994295fa1b7df394ddc528 (patch) | |
tree | f1324b65dbf6a620ff1897f8029f7d611d8cf1a8 | |
parent | Use imagemin to minify images (#323) (diff) | |
download | ferdium-recipes-562ffde69b858b9584994295fa1b7df394ddc528.tar.gz ferdium-recipes-562ffde69b858b9584994295fa1b7df394ddc528.tar.zst ferdium-recipes-562ffde69b858b9584994295fa1b7df394ddc528.zip |
Fixed Slite querySelector and code style improvements (#324)
-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 | ||