-
Notifications
You must be signed in to change notification settings - Fork 2
/
webview.js
23 lines (18 loc) · 4.07 KB
/
webview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
'use strict';
module.exports = Franz => {
const getMessages = function getMessages() {
let count = 0;
if (document.getElementsByClassName('mail-LabelList-Item_count').length > 1) {
count = parseInt(document.getElementsByClassName('mail-LabelList-Item_count')[1].textContent);
}
// Just incase we don't end up with a number, set it back to zero (parseInt can return NaN)
if (isNaN(count)) {
count = 0;
}
// set Franz badge
Franz.setBadge(count);
};
// check for new messages every second and update Franz badge
Franz.loop(getMessages);
};
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImdtYWlsL3dlYnZpZXcuanMiXSwibmFtZXMiOlsibW9kdWxlIiwiZXhwb3J0cyIsIkZyYW56IiwiZ2V0TWVzc2FnZXMiLCJjb3VudCIsImRvY3VtZW50IiwiZ2V0RWxlbWVudHNCeUNsYXNzTmFtZSIsImxlbmd0aCIsImdldEF0dHJpYnV0ZSIsInBhcnNlSW50IiwicmVwbGFjZSIsImlzTmFOIiwic2V0QmFkZ2UiLCJsb29wIl0sIm1hcHBpbmdzIjoiOztBQUFBQSxPQUFPQyxPQUFQLEdBQWtCQyxLQUFELElBQVc7QUFDMUIsUUFBTUMsY0FBYyxTQUFTQSxXQUFULEdBQXVCO0FBQ3pDLFFBQUlDLFFBQVEsQ0FBWjs7QUFFQTtBQUNBO0FBQ0E7O0FBRUE7QUFDQSxRQUFJQyxTQUFTQyxzQkFBVCxDQUFnQyxPQUFoQyxFQUF5Q0MsTUFBekMsR0FBa0QsQ0FBdEQsRUFBeUQ7QUFDdkRILGNBQVFDLFNBQVNDLHNCQUFULENBQWdDLE9BQWhDLEVBQXlDQyxNQUFqRDtBQUNEOztBQUVELFFBQUlGLFNBQVNDLHNCQUFULENBQWdDLFNBQWhDLEVBQTJDQyxNQUEzQyxHQUFvRCxDQUF4RCxFQ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