From 7bcc6b18102725e5d2e737801ff114716c5a6825 Mon Sep 17 00:00:00 2001 From: Joseph Hale <47901316+thehale@users.noreply.github.com> Date: Tue, 23 May 2023 14:32:33 -0700 Subject: fix(github): Include "new notifications" in direct total (#371) --- recipes/github/package.json | 2 +- recipes/github/webview.js | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'recipes') diff --git a/recipes/github/package.json b/recipes/github/package.json index 7562766..fa734c7 100644 --- a/recipes/github/package.json +++ b/recipes/github/package.json @@ -1,7 +1,7 @@ { "id": "github", "name": "GitHub", - "version": "2.5.2", + "version": "2.5.3", "license": "MIT", "config": { "serviceURL": "https://github.com/notifications", 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 @@ module.exports = Ferdium => { + const _parseNewCount = (text) => { + const match = text.match(/\d+/); + return match ? Ferdium.safeParseInt(match[0]) : 0; + }; + const getMessages = () => { const directCountElement = document.querySelector( '.filter-list.js-notification-inboxes .count', ); - const directCount = directCountElement + let directCount = directCountElement ? Ferdium.safeParseInt(directCountElement.textContent) : 0; + + const newCountElement = document.querySelector('a.h6[href="/notifications?query="]'); + const newCount = newCountElement ? + _parseNewCount(newCountElement.textContent) : 0; + directCount += newCount; + const indirectCount = document.querySelector( '[class*="mail-status unread"]:not([hidden])', ) ? 1 : 0; -- cgit v1.2.3-54-g00ecf