diff options
Diffstat (limited to 'recipes/whereby/webview.js')
-rw-r--r-- | recipes/whereby/webview.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/recipes/whereby/webview.js b/recipes/whereby/webview.js new file mode 100644 index 0000000..0e5529e --- /dev/null +++ b/recipes/whereby/webview.js | |||
@@ -0,0 +1,25 @@ | |||
1 | var _path = _interopRequireDefault(require('path')); | ||
2 | |||
3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
4 | |||
5 | module.exports = Ferdi => { | ||
6 | const getMessages = function getMessages() { | ||
7 | const elements = document.querySelectorAll('.CxUIE, .unread'); | ||
8 | let count = 0; | ||
9 | |||
10 | for (let i = 0; i < elements.length; i += 1) { | ||
11 | if (elements[i].querySelectorAll('*[data-icon="muted"]').length === 0) { | ||
12 | count += 1; | ||
13 | } | ||
14 | } | ||
15 | |||
16 | // set Ferdi badge | ||
17 | Ferdi.setBadge(count); | ||
18 | }; | ||
19 | |||
20 | // check for new messages every second and update Ferdi badge | ||
21 | Ferdi.loop(getMessages); | ||
22 | |||
23 | // inject Ferdi.css stylesheet | ||
24 | Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
25 | }; | ||