diff options
Diffstat (limited to 'recipes/github')
-rw-r--r-- | recipes/github/package.json | 2 | ||||
-rw-r--r-- | recipes/github/webview.js | 38 |
2 files changed, 12 insertions, 28 deletions
diff --git a/recipes/github/package.json b/recipes/github/package.json index 8788aad..e077f8d 100644 --- a/recipes/github/package.json +++ b/recipes/github/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "github", | 2 | "id": "github", |
3 | "name": "GitHub", | 3 | "name": "GitHub", |
4 | "version": "2.6.0", | 4 | "version": "2.6.1", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://github.com/notifications", | 7 | "serviceURL": "https://github.com/notifications", |
diff --git a/recipes/github/webview.js b/recipes/github/webview.js index 3068b80..c3f653f 100644 --- a/recipes/github/webview.js +++ b/recipes/github/webview.js | |||
@@ -5,36 +5,20 @@ function _interopRequireDefault(obj) { | |||
5 | const _path = _interopRequireDefault(require('path')); | 5 | const _path = _interopRequireDefault(require('path')); |
6 | 6 | ||
7 | module.exports = Ferdium => { | 7 | module.exports = Ferdium => { |
8 | const _parseNewCount = text => { | 8 | const newCountMatch = document |
9 | const match = text.match(/\d+/); | 9 | .querySelector('a.h6[href="/notifications?query="]') |
10 | return match ? Ferdium.safeParseInt(match[0]) : 0; | 10 | ?.textContent?.match(/\d+/); |
11 | }; | ||
12 | |||
13 | const getMessages = () => { | 11 | const getMessages = () => { |
14 | const directCountElement = document.querySelector( | 12 | Ferdium.setBadge( |
15 | '.filter-list.js-notification-inboxes .count', | 13 | Ferdium.safeParseInt( |
16 | ); | 14 | document.querySelector('.filter-list.js-notification-inboxes .count') |
17 | let directCount = directCountElement | 15 | ?.textContent, |
18 | ? Ferdium.safeParseInt(directCountElement.textContent) | 16 | ) + Ferdium.safeParseInt(newCountMatch ? newCountMatch[0] : 0), |
19 | : 0; | 17 | document.querySelectorAll( |
20 | 18 | '#AppHeader-notifications-button.AppHeader-button--hasIndicator', | |
21 | const newCountElement = document.querySelector( | 19 | ).length, |
22 | 'a.h6[href="/notifications?query="]', | ||
23 | ); | 20 | ); |
24 | const newCount = newCountElement | ||
25 | ? _parseNewCount(newCountElement.textContent) | ||
26 | : 0; | ||
27 | directCount += newCount; | ||
28 | |||
29 | const indirectCount = document.querySelector( | ||
30 | '[class*="mail-status unread"]:not([hidden])', | ||
31 | ) | ||
32 | ? 1 | ||
33 | : 0; | ||
34 | Ferdium.setBadge(directCount, indirectCount); | ||
35 | }; | 21 | }; |
36 | |||
37 | Ferdium.loop(getMessages); | 22 | Ferdium.loop(getMessages); |
38 | |||
39 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | 23 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); |
40 | }; | 24 | }; |