From a7674ffb0f3f1c38adddfcdcefbe0851bcf25acb Mon Sep 17 00:00:00 2001 From: Edmundo Sanchez Date: Tue, 13 Sep 2022 01:40:26 -0500 Subject: Add service OnMail (#174) --- recipes/onmail/webview.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 recipes/onmail/webview.js (limited to 'recipes/onmail/webview.js') diff --git a/recipes/onmail/webview.js b/recipes/onmail/webview.js new file mode 100644 index 0000000..8565d76 --- /dev/null +++ b/recipes/onmail/webview.js @@ -0,0 +1,22 @@ +const _path = _interopRequireDefault(require('path')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; +} + +module.exports = Ferdium => { + const getMessages = () => { + let countImportant = 0; + const inboxLinks = document.querySelectorAll('p.truncate'); + for (const label of inboxLinks){ + if (label.textContent) { + countImportant = Ferdium.safeParseInt(label.nextSibling.textContent); + break; + } + } + Ferdium.setBadge(countImportant, 0); + }; + Ferdium.loop(getMessages); + + Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); +}; -- cgit v1.2.3-70-g09d2