diff options
author | 2019-12-11 11:35:39 +0100 | |
---|---|---|
committer | 2019-12-11 11:35:39 +0100 | |
commit | 2491ea3c11de71391cd333cfc375576232d64cba (patch) | |
tree | cfc7b178be929d59ae75ae6ff419b3c11b3474a2 /uncompressed/hangoutschat/webview.js | |
parent | Fix update error (diff) | |
download | ferdium-recipes-2491ea3c11de71391cd333cfc375576232d64cba.tar.gz ferdium-recipes-2491ea3c11de71391cd333cfc375576232d64cba.tar.zst ferdium-recipes-2491ea3c11de71391cd333cfc375576232d64cba.zip |
Update packages
Diffstat (limited to 'uncompressed/hangoutschat/webview.js')
-rw-r--r-- | uncompressed/hangoutschat/webview.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/uncompressed/hangoutschat/webview.js b/uncompressed/hangoutschat/webview.js index 2af9e03..27a2016 100644 --- a/uncompressed/hangoutschat/webview.js +++ b/uncompressed/hangoutschat/webview.js | |||
@@ -1,13 +1,10 @@ | |||
1 | 'use strict'; | 1 | "use strict"; |
2 | 2 | ||
3 | module.exports = Franz => { | 3 | module.exports = Franz => { |
4 | const getMessages = function getMessages() { | 4 | const getMessages = function getMessages() { |
5 | const muteSelector = '.DQy0Rb'; | 5 | const muteSelector = '.DQy0Rb'; |
6 | |||
7 | // get unread messages | ||
8 | let directCount = 0; | 6 | let directCount = 0; |
9 | document.querySelectorAll('.eM5l9e.FVKzAb').forEach(node => { | 7 | document.querySelectorAll('.eM5l9e.FVKzAb').forEach(node => { |
10 | // Hangouts Chat overrides the muted indicator when there is a direct mention | ||
11 | if (!node.closest('content[role="listitem"]').querySelector(muteSelector)) { | 8 | if (!node.closest('content[role="listitem"]').querySelector(muteSelector)) { |
12 | directCount += 1; | 9 | directCount += 1; |
13 | } | 10 | } |
@@ -19,12 +16,21 @@ module.exports = Franz => { | |||
19 | } | 16 | } |
20 | }); | 17 | }); |
21 | indirectCount -= directCount; | 18 | indirectCount -= directCount; |
22 | |||
23 | // set Franz badge | ||
24 | Franz.setBadge(directCount, indirectCount); | 19 | Franz.setBadge(directCount, indirectCount); |
25 | }; | 20 | }; |
26 | 21 | ||
27 | // check for new messages every second and update Franz badge | 22 | document.addEventListener('click', e => { |
23 | const { | ||
24 | tagName, | ||
25 | target, | ||
26 | href | ||
27 | } = e.target; | ||
28 | |||
29 | if (tagName === 'A' && target === '_blank') { | ||
30 | e.preventDefault(); | ||
31 | e.stopImmediatePropagation(); | ||
32 | window.open(href); | ||
33 | } | ||
34 | }); | ||
28 | Franz.loop(getMessages); | 35 | Franz.loop(getMessages); |
29 | }; | 36 | }; \ No newline at end of file |
30 | //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImhhbmdvdXRzY2hhdC93ZWJ2aWV3LmpzIl0sIm5hbWVzIjpbIm1vZHVsZSIsImV4cG9ydHMiLCJGcmFueiIsImdldE1lc3NhZ2VzIiwibXV0ZVNlbGVjdG9yIiwiZGlyZWN0Q291bnQiLCJkb2N1bWVudCIsInF1ZXJ5U2VsZWN0b3JBbGwiLCJmb3JFYWNoIiwibm9kZSIsImNsb3Nlc3QiLCJxdWVyeVNlbGVjdG9yIiwiaW5kaXJlY3RDb3VudCIsInNldEJhZGdlIiwibG9vcCJdLCJtYXBwaW5ncyI6Ijs7QUFBQUEsT0FBT0MsT0FBUCxHQUFrQkMsS0FBRCxJQUFXO0FBQzFCLFFBQU1DLGNBQWMsU0FBU0EsV0FBVCxHQUF1QjtBQUN6QyxVQUFNQyxlQUFlLFNBQXJCOztBQUVBO0FBQ0EsUUFBSUMsY0FBYyxDQUFsQjtBQUNBQyxhQUFTQyxnQkFBVCxDQUEwQixnQkFBMUIsRUFBNENDLE9BQTVDLENBQXFEQyxJQUFELElBQVU7QUFDNUQ7QUFDQSxVQUFJLENBQUNBLEtBQUtDLE9BQUwsQ0FBYSwwQkFBYixFQUF5Q0MsYUFBekMsQ0FBdURQLFlBQXZELENBQUwsRUFBMkU7QUFDekVDLHVCQUFlLENBQWY7QUFDRDtB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