From 5c2409c123a38ee2a7e412914ba5bd486cdfa5bf Mon Sep 17 00:00:00 2001 From: Victor Bonnelle Date: Wed, 19 Jul 2023 22:10:15 +0200 Subject: [PATCH] Add Skiff Mail recipe --- 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 diff --git a/recipes/skiff-mail/icon.svg b/recipes/skiff-mail/icon.svg new file mode 100644 index 000000000..f64997d75 --- /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 000000000..dd41f7287 --- /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 000000000..1193c8219 --- /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 000000000..522b06266 --- /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')); +};