From e2b06809981fca02ef6337b6ac0a5c28ec70a996 Mon Sep 17 00:00:00 2001 From: Jalil Salamé <60845989+jalil-salame@users.noreply.github.com> Date: Fri, 12 May 2023 06:27:24 +0200 Subject: Add Elk recipe (#358) Elk is a modern Mastodon web client, you can check it out at https://elk.zone/ --- recipes/elk/icon.svg | 1 + recipes/elk/index.js | 1 + recipes/elk/package.json | 10 ++++++++++ recipes/elk/webview.js | 23 +++++++++++++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 recipes/elk/icon.svg create mode 100644 recipes/elk/index.js create mode 100644 recipes/elk/package.json create mode 100644 recipes/elk/webview.js (limited to 'recipes') diff --git a/recipes/elk/icon.svg b/recipes/elk/icon.svg new file mode 100644 index 0000000..90730e6 --- /dev/null +++ b/recipes/elk/icon.svg @@ -0,0 +1 @@ + diff --git a/recipes/elk/index.js b/recipes/elk/index.js new file mode 100644 index 0000000..dd41f72 --- /dev/null +++ b/recipes/elk/index.js @@ -0,0 +1 @@ +module.exports = Ferdium => Ferdium; diff --git a/recipes/elk/package.json b/recipes/elk/package.json new file mode 100644 index 0000000..3f6c001 --- /dev/null +++ b/recipes/elk/package.json @@ -0,0 +1,10 @@ +{ + "id": "elk", + "name": "Elk", + "version": "1.0.0", + "license": "MIT", + "repository": "https://github.com/jalil-salame/ferdium-elk-recipe", + "config": { + "serviceURL": "https://elk.zone/" + } +} diff --git a/recipes/elk/webview.js b/recipes/elk/webview.js new file mode 100644 index 0000000..f284fd3 --- /dev/null +++ b/recipes/elk/webview.js @@ -0,0 +1,23 @@ +const _path = _interopRequireDefault(require('path')); + +function _interopRequireDefault(obj) { + return obj && obj.__esModule ? obj : { default: obj }; +} + +module.exports = (Ferdium) => { + // Inject css + Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); + + // Get notifications + Ferdium.loop(() => { + const notifications = document.querySelectorAll("[href$=notifications]").item(0); + // Null if not present + if (!notifications) { + return; + } + // Assume first element contains the number of notifications + let parsedValue = Ferdium.safeParseInt(notifications.outerText); + // Set to parsed value + Ferdium.setBadge(parsedValue); + }); +} -- cgit v1.2.3-54-g00ecf