diff options
author | 2021-10-05 17:04:09 +0200 | |
---|---|---|
committer | 2021-10-05 17:04:09 +0200 | |
commit | d3841b766f9d37d557646003899f67525c5f755f (patch) | |
tree | 1bcab990c94f2b05678b7a83ffebe08298500f0b /recipes/gmail/webview.js | |
parent | chore: repo maintenance (#732) (diff) | |
download | ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.gz ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.tar.zst ferdium-recipes-d3841b766f9d37d557646003899f67525c5f755f.zip |
chore: add eslint-plugin-unicorn (#733)
Diffstat (limited to 'recipes/gmail/webview.js')
-rw-r--r-- | recipes/gmail/webview.js | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/recipes/gmail/webview.js b/recipes/gmail/webview.js index 23b1382..9b94d33 100644 --- a/recipes/gmail/webview.js +++ b/recipes/gmail/webview.js | |||
@@ -1,21 +1,33 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | 1 | const _path = _interopRequireDefault(require('path')); |
2 | 2 | ||
3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 3 | function _interopRequireDefault(obj) { |
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
4 | 6 | ||
5 | module.exports = (Ferdi) => { | 7 | module.exports = Ferdi => { |
6 | // if the user is on gmail's landing page, go to the login page. | 8 | // if the user is on gmail's landing page, go to the login page. |
7 | if (location.hostname == 'www.google.com' && location.href.includes('gmail/about/')) { | 9 | if ( |
8 | location.href = 'https://accounts.google.com/AccountChooser?service=mail&continue=https://mail.google.com/mail/'; | 10 | location.hostname == 'www.google.com' && |
11 | location.href.includes('gmail/about/') | ||
12 | ) { | ||
13 | location.href = | ||
14 | 'https://accounts.google.com/AccountChooser?service=mail&continue=https://mail.google.com/mail/'; | ||
9 | } | 15 | } |
10 | 16 | ||
11 | const getMessages = () => { | 17 | const getMessages = () => { |
12 | let count = 0; | 18 | let count = 0; |
13 | 19 | ||
14 | const inboxLinks = document.getElementsByClassName('J-Ke n0'); | 20 | const inboxLinks = document.querySelectorAll('.J-Ke.n0'); |
15 | if (inboxLinks.length > 0) { | 21 | if (inboxLinks.length > 0) { |
16 | const unreadCounts = inboxLinks[0].parentNode.parentNode.getElementsByClassName('bsU'); | 22 | let parentNode = inboxLinks[0].parentNode; |
17 | if (unreadCounts.length > 0) { | 23 | if (parentNode) { |
18 | count = Ferdi.safeParseInt(unreadCounts[0].innerHTML); | 24 | let parentNodeOfParentNode = parentNode.parentNode; |
25 | if (parentNodeOfParentNode) { | ||
26 | const unreadCounts = parentNodeOfParentNode.querySelectorAll('.bsU'); | ||
27 | if (unreadCounts.length > 0) { | ||
28 | count = Ferdi.safeParseInt(unreadCounts[0].textContent); | ||
29 | } | ||
30 | } | ||
19 | } | 31 | } |
20 | } | 32 | } |
21 | 33 | ||