From 57fffb6572dd4fa8257357b42448cd2bbeb8d586 Mon Sep 17 00:00:00 2001 From: vantezzen Date: Mon, 22 Jun 2020 10:40:27 +0200 Subject: Update repository --- uncompressed/workplace/index.js | 3 +-- uncompressed/workplace/package.json | 10 ++++---- uncompressed/workplace/webview.js | 47 ++++++++++++++++++++++++++++++++----- 3 files changed, 47 insertions(+), 13 deletions(-) (limited to 'uncompressed/workplace') diff --git a/uncompressed/workplace/index.js b/uncompressed/workplace/index.js index c638730..e8243fb 100644 --- a/uncompressed/workplace/index.js +++ b/uncompressed/workplace/index.js @@ -1,4 +1,3 @@ "use strict"; -module.exports = Franz => Franz; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndvcmtwbGFjZS9pbmRleC5qcyJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwiRnJhbnoiXSwibWFwcGluZ3MiOiI7O0FBQUFBLE9BQU9DLE9BQVAsR0FBaUJDLFNBQVNBLEtBQTFCIiwiZmlsZSI6IndvcmtwbGFjZS9pbmRleC5qcyIsInNvdXJjZXNDb250ZW50IjpbIm1vZHVsZS5leHBvcnRzID0gRnJhbnogPT4gRnJhbno7XG4iXX0= \ No newline at end of file +module.exports = Franz => Franz; \ No newline at end of file diff --git a/uncompressed/workplace/package.json b/uncompressed/workplace/package.json index 596daea..cb2193f 100644 --- a/uncompressed/workplace/package.json +++ b/uncompressed/workplace/package.json @@ -1,16 +1,16 @@ { "id": "workplace", "name": "Workplace", - "version": "1.0.0", + "version": "1.1.1", "description": "Workplace by facebook", "main": "index.js", - "author": "Rico Herwig ", + "author": "Rico Herwig , Stefan Malzner ", "license": "MIT", "config": { - "serviceURL": "https://{teamId}.facebook.com/chat", + "serviceURL": "https://{teamId}.workplace.com/chat", "hasNotificationSound": true, "hasDirectMessages": true, "hasTeamId": true, - "urlInputSuffix": ".facebook.com" + "urlInputSuffix": ".workplace.com" } - } \ No newline at end of file + } 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 @@ -'use strict'; +"use strict"; const path = require('path'); module.exports = Franz => { const getMessages = () => { - const $messages = document.querySelector('.uiScrollableAreaContent'); - const $unreadMessages = $messages.querySelectorAll('._1ht3 ._1ht6'); + let direct = 0; + let indirect = 0; + const chatsElement = document.querySelector('#chats'); + const notifications = document.querySelector('#notifications span span'); - Franz.setBadge($unreadMessages.length); + if (notifications) { + indirect = parseInt(notifications.innerText, 10); + } + + if (chatsElement) { + if (!chatsElement.hasAttribute('aria-current')) { + const chatMessages = chatsElement.querySelector('span'); + + if (chatMessages) { + direct = parseInt(chatMessages.innerText, 10); + } + } else { + direct = document.querySelectorAll('[data-pagelet="WorkGalahadChannel"] .uiList [role="gridcell"] [role="button"] .oxk9n0fw').length; + } + } + + Franz.setBadge(direct, indirect); }; Franz.injectCSS(path.join(__dirname, 'workplace.css')); Franz.loop(getMessages); -}; -//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndvcmtwbGFjZS93ZWJ2aWV3LmpzIl0sIm5hbWVzIjpbInBhdGgiLCJyZXF1aXJlIiwibW9kdWxlIiwiZXhwb3J0cyIsIkZyYW56IiwiZ2V0TWVzc2FnZXMiLCIkbWVzc2FnZXMiLCJkb2N1bWVudCIsInF1ZXJ5U2VsZWN0b3IiLCIkdW5yZWFkTWVzc2FnZXMiLCJxdWVyeVNlbGVjdG9yQWxsIiwic2V0QmFkZ2UiLCJsZW5ndGgiLCJpbmplY3RDU1MiLCJqb2luIiwiX19kaXJuYW1lIiwibG9vcCJdLCJtYXBwaW5ncyI6Ijs7QUFBQSxNQUFNQSxPQUFPQyxRQUFRLE1BQVIsQ0FBYjs7QUFFQUMsT0FBT0MsT0FBUCxHQUFrQkMsS0FBRCxJQUFXO0FBQzFCLFFBQU1DLGNBQWMsTUFBTTtBQUN4QixVQUFNQyxZQUFZQyxTQUFTQyxhQUFULENBQXVCLDBCQUF2QixDQUFsQjtBQUNBLFVBQU1DLGtCQUFrQkgsVUFBVUksZ0JBQVYsQ0FBMkIsZUFBM0IsQ0FBeEI7O0FBRUFOLFVBQU1PLFFBQU4sQ0FBZUYsZ0JBQWdCRyxNQUEvQjtBQUNELEdBTEQ7O0FBT0FSLFFBQU1TLFNBQU4sQ0FBZ0JiLEtBQUtjLElBQUwsQ0FBVUMsU0FBVixFQUFxQixlQUFyQixDQUFoQjtBQUNBWCxRQUFNWSxJQUFOLENBQVdYLFdBQVg7QUFDRCxDQVZEIiwiZmlsZSI6IndvcmtwbGFjZS93ZWJ2aWV3LmpzIiwic291cmNlc0NvbnRlbnQiOlsiY29uc3QgcGF0aCA9IHJlcXVpcmUoJ3BhdGgnKTtcblxubW9kdWxlLmV4cG9ydHMgPSAoRnJhbnopID0+IHtcbiAgY29uc3QgZ2V0TWVzc2FnZXMgPSAoKSA9PiB7XG4gICAgY29uc3QgJG1lc3NhZ2VzID0gZG9jdW1lbnQucXVlcnlTZWxlY3RvcignLnVpU2Nyb2xsYWJsZUFyZWFDb250ZW50Jyk7XG4gICAgY29uc3QgJHVucmVhZE1lc3NhZ2VzID0gJG1lc3NhZ2VzLnF1ZXJ5U2VsZWN0b3JBbGwoJy5fMWh0MyAuXzFodDYnKTtcblxuICAgIEZyYW56LnNldEJhZGdlKCR1bnJlYWRNZXNzYWdlcy5sZW5ndGgpO1xuICB9O1xuXG4gIEZyYW56LmluamVjdENTUyhwYXRoLmpvaW4oX19kaXJuYW1lLCAnd29ya3BsYWNlLmNzcycpKTtcbiAgRnJhbnoubG9vcChnZXRNZXNzYWdlcyk7XG59O1xuIl19 \ No newline at end of file + localStorage._cs_desktopNotifsEnabled = JSON.stringify({ + __t: new Date().getTime(), + __v: true + }); + + if (typeof Franz.onNotify === 'function') { + Franz.onNotify(notification => { + if (typeof notification.title !== 'string') { + notification.title = ((notification.title.props || {}).content || [])[0] || 'Work Chat'; + } + + if (typeof notification.options.body !== 'string') { + notification.options.body = (((notification.options.body || {}).props || {}).content || [])[0] || ''; + } + + return notification; + }); + } +}; \ No newline at end of file -- cgit v1.2.3-70-g09d2