From 51795708d22d25f8ffda5740fa2875156ba1edb5 Mon Sep 17 00:00:00 2001 From: Luca Camillo Date: Mon, 10 Jan 2022 09:58:57 +0100 Subject: [PATCH 1/3] stronger chat counter --- webview.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) 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); }; From 6242be0d65025bfd5d75a7bf945025dfde2beafa Mon Sep 17 00:00:00 2001 From: Luca Camillo Date: Mon, 10 Jan 2022 10:00:14 +0100 Subject: [PATCH 2/3] add new host that require origin set the same as referer --- index.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 3a8cbb9..e70669a 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: ['*://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/*'] + } }]; } From 3310f29066b34c9918aac0e57d3032ae54a21eee Mon Sep 17 00:00:00 2001 From: Luca Camillo Date: Fri, 14 Jan 2022 16:07:04 +0100 Subject: [PATCH 3/3] add new host --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index e70669a..bc66e95 100644 --- a/index.js +++ b/index.js @@ -7,7 +7,7 @@ module.exports = Franz => class Gmail extends Franz { origin: 'RefererHost' }, requestFilters: { - urls: ['*://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/*'] + 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/*'] } }]; }