diff --git a/index.js b/index.js index 3a8cbb9..bc66e95 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,14 @@ +"use strict"; + module.exports = Franz => class Gmail extends Franz { modifyRequestHeaders() { return [{ headers: { - origin: 'RefererHost', + origin: 'RefererHost' }, requestFilters: { - urls: [ - '*://people-pa.clients6.google.com/*', '*://clients6.google.com/drive/*', '*://clients6.google.com/gmail/*', '*://signaler-pa.clients6.google.com/*', '*://addons-pa.clients6.google.com/*', - '*://chat-pa.clients6.google.com/*', '*://clients6.google.com/voice/*', '*://hangouts.google.com/*', - '*://peoplestack-pa.clients6.google.com/*', '*://calendar-pa.clients6.google.com/*', '*://play.google.com/*'], - }, + urls: ['*://taskassist-pa.clients6.google.com/*', '*://people-pa.clients6.google.com/*', '*://peoplestackwebexperiments-pa.clients6.google.com/*', '*://clients6.google.com/drive/*', '*://clients6.google.com/gmail/*', '*://signaler-pa.clients6.google.com/*', '*://addons-pa.clients6.google.com/*', '*://chat-pa.clients6.google.com/*', '*://clients6.google.com/voice/*', '*://hangouts.google.com/*', '*://peoplestack-pa.clients6.google.com/*', '*://calendar-pa.clients6.google.com/*', '*://play.google.com/*'] + } }]; } diff --git a/webview.js b/webview.js index 5616db7..d5e0ff1 100644 --- a/webview.js +++ b/webview.js @@ -1,4 +1,6 @@ -import path from 'path'; +"use strict"; + +const path = require('path'); module.exports = (Franz) => { const getMessages = function getMessages() { @@ -6,21 +8,23 @@ module.exports = (Franz) => { if (document.getElementsByClassName('J-Ke n0').length > 0) { if (document.getElementsByClassName('J-Ke n0')[0].getAttribute('aria-label') != null) { - count = parseInt(document.getElementsByClassName('J-Ke n0')[0].getAttribute('aria-label').replace(/[^0-9.]/g, ''), 10); + count = parseInt(document.getElementsByClassName('J-Ke n0')[0].getAttribute('aria-label').replace(/[^\d]/g, ''), 10); + if (isNaN(count)) { + count = 0; + } } } - const chatCount = parseInt((document.querySelector('[data-tooltip="Chat"]') || '').ariaLabel.replace(/[^\d]/g, ''), 10) || 0; - - - // Just incase we don't end up with a number, set it back to zero (parseInt can return NaN) - count = parseInt(count, 10); - if (isNaN(count)) { - count = 0; + if (document.querySelector('[data-tooltip="Chat"]')) { + if (document.querySelector('[data-tooltip="Chat"]').getAttribute('aria-label')){ + let chatCount = parseInt(document.querySelector('[data-tooltip="Chat"]').getAttribute('aria-label').replace(/[^\d]/g, ''), 10); + if (isNaN(chatCount)) { + chatCount = 0; + } + count += chatCount; + } } - count += chatCount; - // set Franz badge Franz.setBadge(count); };