aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/github/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/github/webview.js')
-rw-r--r--recipes/github/webview.js13
1 files changed, 12 insertions, 1 deletions
diff --git a/recipes/github/webview.js b/recipes/github/webview.js
index 1023975..b73e96e 100644
--- a/recipes/github/webview.js
+++ b/recipes/github/webview.js
@@ -1,11 +1,22 @@
1module.exports = Ferdium => { 1module.exports = Ferdium => {
2 const _parseNewCount = (text) => {
3 const match = text.match(/\d+/);
4 return match ? Ferdium.safeParseInt(match[0]) : 0;
5 };
6
2 const getMessages = () => { 7 const getMessages = () => {
3 const directCountElement = document.querySelector( 8 const directCountElement = document.querySelector(
4 '.filter-list.js-notification-inboxes .count', 9 '.filter-list.js-notification-inboxes .count',
5 ); 10 );
6 const directCount = directCountElement 11 let directCount = directCountElement
7 ? Ferdium.safeParseInt(directCountElement.textContent) 12 ? Ferdium.safeParseInt(directCountElement.textContent)
8 : 0; 13 : 0;
14
15 const newCountElement = document.querySelector('a.h6[href="/notifications?query="]');
16 const newCount = newCountElement ?
17 _parseNewCount(newCountElement.textContent) : 0;
18 directCount += newCount;
19
9 const indirectCount = document.querySelector( 20 const indirectCount = document.querySelector(
10 '[class*="mail-status unread"]:not([hidden])', 21 '[class*="mail-status unread"]:not([hidden])',
11 ) ? 1 : 0; 22 ) ? 1 : 0;