From d028830bc9e474115973bdc79fbac150bce054aa Mon Sep 17 00:00:00 2001 From: Victor B <39555268+victorbnl@users.noreply.github.com> Date: Thu, 20 Jul 2023 01:32:47 +0200 Subject: Add Skiff Mail recipe (#391) --- recipes/skiff-mail/icon.svg | 1 + recipes/skiff-mail/index.js | 1 + recipes/skiff-mail/package.json | 9 +++++++++ recipes/skiff-mail/webview.js | 17 +++++++++++++++++ 4 files changed, 28 insertions(+) create mode 100644 recipes/skiff-mail/icon.svg create mode 100644 recipes/skiff-mail/index.js create mode 100644 recipes/skiff-mail/package.json create mode 100644 recipes/skiff-mail/webview.js (limited to 'recipes') diff --git a/recipes/skiff-mail/icon.svg b/recipes/skiff-mail/icon.svg new file mode 100644 index 0000000..f64997d --- /dev/null +++ b/recipes/skiff-mail/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/recipes/skiff-mail/index.js b/recipes/skiff-mail/index.js new file mode 100644 index 0000000..dd41f72 --- /dev/null +++ b/recipes/skiff-mail/index.js @@ -0,0 +1 @@ +module.exports = Ferdium => Ferdium; diff --git a/recipes/skiff-mail/package.json b/recipes/skiff-mail/package.json new file mode 100644 index 0000000..1193c82 --- /dev/null +++ b/recipes/skiff-mail/package.json @@ -0,0 +1,9 @@ +{ + "id": "skiff-mail", + "name": "Skiff Mail", + "version": "1.0.0", + "license": "MIT", + "config": { + "serviceURL": "https://app.skiff.com/mail/inbox" + } +} diff --git a/recipes/skiff-mail/webview.js b/recipes/skiff-mail/webview.js new file mode 100644 index 0000000..522b062 --- /dev/null +++ b/recipes/skiff-mail/webview.js @@ -0,0 +1,17 @@ +const _path = _interopRequireDefault(require('path')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; +} + +module.exports = Ferdium => { + const getMessages = () => { + const element = document.querySelector('div[href="/mail/inbox"]'); + const matches = element.textContent.match(/\d+/); + const unreadCount = Ferdium.safeParseInt(matches ? matches[0] : 0); + Ferdium.setBadge(unreadCount); + }; + Ferdium.loop(getMessages); + + Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); +}; -- cgit v1.2.3-54-g00ecf