diff options
author | vantezzen <hello@vantezzen.io> | 2020-06-22 10:40:27 +0200 |
---|---|---|
committer | vantezzen <hello@vantezzen.io> | 2020-06-22 10:40:27 +0200 |
commit | 57fffb6572dd4fa8257357b42448cd2bbeb8d586 (patch) | |
tree | 73f8c766150bc4a37382cb10929fb2e4758bbfc7 /uncompressed/workplace/webview.js | |
parent | Repackaged #206 (diff) | |
download | ferdium-recipes-57fffb6572dd4fa8257357b42448cd2bbeb8d586.tar.gz ferdium-recipes-57fffb6572dd4fa8257357b42448cd2bbeb8d586.tar.zst ferdium-recipes-57fffb6572dd4fa8257357b42448cd2bbeb8d586.zip |
Update repository
Diffstat (limited to 'uncompressed/workplace/webview.js')
-rw-r--r-- | uncompressed/workplace/webview.js | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/uncompressed/workplace/webview.js b/uncompressed/workplace/webview.js index c1df892..a26515e 100644 --- a/uncompressed/workplace/webview.js +++ b/uncompressed/workplace/webview.js | |||
@@ -1,16 +1,51 @@ | |||
1 | 'use strict'; | 1 | "use strict"; |
2 | 2 | ||
3 | const path = require('path'); | 3 | const path = require('path'); |
4 | 4 | ||
5 | module.exports = Franz => { | 5 | module.exports = Franz => { |
6 | const getMessages = () => { | 6 | const getMessages = () => { |
7 | const $messages = document.querySelector('.uiScrollableAreaContent'); | 7 | let direct = 0; |
8 | const $unreadMessages = $messages.querySelectorAll('._1ht3 ._1ht6'); | 8 | let indirect = 0; |
9 | const chatsElement = document.querySelector('#chats'); | ||
10 | const notifications = document.querySelector('#notifications span span'); | ||
9 | 11 | ||
10 | Franz.setBadge($unreadMessages.length); | 12 | if (notifications) { |
13 | indirect = parseInt(notifications.innerText, 10); | ||
14 | } | ||
15 | |||
16 | if (chatsElement) { | ||
17 | if (!chatsElement.hasAttribute('aria-current')) { | ||
18 | const chatMessages = chatsElement.querySelector('span'); | ||
19 | |||
20 | if (chatMessages) { | ||
21 | direct = parseInt(chatMessages.innerText, 10); | ||
22 | } | ||
23 | } else { | ||
24 | direct = document.querySelectorAll('[data-pagelet="WorkGalahadChannel"] .uiList [role="gridcell"] [role="button"] .oxk9n0fw').length; | ||
25 | } | ||
26 | } | ||
27 | |||
28 | Franz.setBadge(direct, indirect); | ||
11 | }; | 29 | }; |
12 | 30 | ||
13 | Franz.injectCSS(path.join(__dirname, 'workplace.css')); | 31 | Franz.injectCSS(path.join(__dirname, 'workplace.css')); |
14 | Franz.loop(getMessages); | 32 | Franz.loop(getMessages); |
15 | }; | 33 | localStorage._cs_desktopNotifsEnabled = JSON.stringify({ |
16 | //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndvcmtwbGFjZS93ZWJ2aWV3LmpzIl0sIm5hbWVzIjpbInBhdGgiLCJyZXF1aXJlIiwibW9kdWxlIiwiZXhwb3J0cyIsIkZyYW56IiwiZ2V0TWVzc2FnZXMiLCIkbWVzc2FnZXMiLCJkb2N1bWVudCIsInF1ZXJ5U2VsZWN0b3IiLCIkdW5yZWFkTWVzc2FnZXMiLCJxdWVyeVNlbGVjdG9yQWxsIiwic2V0QmFkZ2UiLCJsZW5ndGgiLCJpbmplY3RDU1MiLCJqb2luIiwiX19kaXJuYW1lIiwibG9vcCJdLCJtYXBwaW5ncyI6Ijs7QUFBQSxNQUFNQSxPQUFPQyxRQUFRLE1BQVIsQ0FBYjs7QUFFQUMsT0FBT0MsT0FBUCxHQUFrQkMsS0FBRCxJQUFXO0FBQzFCLFFBQU1DLGNBQWMsTUFBTTtBQUN4QixVQUFNQyxZQUFZQyxTQUFTQyxhQUFULENBQXVCLDBCQUF2QixDQUFsQjtBQUNBLFVBQU1DLGtCQUFrQkgsVUFBVUksZ0JBQVYsQ0FBMkIsZUFBM0IsQ0FBeEI7O0FBRUFOLFVBQU1PLFFBQU4sQ0FBZUYsZ0JBQWdCRyxNQUEvQjtBQUNELEdBTEQ7O0FBT0FSLFFBQU1TLFNBQU4sQ0FBZ0JiLEtBQUtjLElBQUwsQ0FBVUMsU0FBVixFQUFxQixlQUFyQixDQUFoQjtBQUNBWCxRQUFNWSxJQUFOLENBQVdYLFdBQVg7QUFDRCxDQVZEIiwiZmlsZSI6IndvcmtwbGFjZS93ZWJ2aWV3LmpzIiwic291cmNlc0NvbnRlbnQiOlsiY29uc3QgcGF0aCA9IHJlcXVpcmUoJ3BhdGgnKTtcblxubW9kdWxlLmV4cG9ydHMgPSAoRnJhbnopID0+IHtcbiAgY29uc3QgZ2V0TWVzc2FnZXMgPSAoKSA9PiB7XG4gICAgY29uc3QgJG1lc3NhZ2VzID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcignLnVpU2Nyb2xsYWJsZUFyZWFDb250ZW50Jyk7XG4gICAgY29uc3QgJHVucmVhZE1lc3NhZ2VzID0gJG1lc3NhZ2VzLnF1ZXJ5U2VsZWN0b3JBbGwoJy5fMWh0MyAuXzFodDYnKTtcblxuICAgIEZyYW56LnNldEJhZGdlKCR1bnJlYWRNZXNzYWdlcy5sZW5ndGgpO1xuICB9O1xuXG4gIEZyYW56LmluamVjdENTUyhwYXRoLmpvaW4oX19kaXJuYW1lLCAnd29ya3BsYWNlLmNzcycpKTtcbiAgRnJhbnoubG9vcChnZXRNZXNzYWdlcyk7XG59O1xuIl19 \ No newline at end of file | 34 | __t: new Date().getTime(), |
35 | __v: true | ||
36 | }); | ||
37 | |||
38 | if (typeof Franz.onNotify === 'function') { | ||
39 | Franz.onNotify(notification => { | ||
40 | if (typeof notification.title !== 'string') { | ||
41 | notification.title = ((notification.title.props || {}).content || [])[0] || 'Work Chat'; | ||
42 | } | ||
43 | |||
44 | if (typeof notification.options.body !== 'string') { | ||
45 | notification.options.body = (((notification.options.body || {}).props || {}).content || [])[0] || ''; | ||
46 | } | ||
47 | |||
48 | return notification; | ||
49 | }); | ||
50 | } | ||
51 | }; \ No newline at end of file | ||