From 32db3ac916192c1acc354663cfd264f56e1304c6 Mon Sep 17 00:00:00 2001 From: Jan Kischel Date: Wed, 2 Nov 2022 19:54:10 +0100 Subject: added new recipe for ntfy.sh notification service (#222) --- recipes/ntfy/icon.svg | 1 + recipes/ntfy/index.js | 1 + recipes/ntfy/package.json | 17 +++++++++++++++++ recipes/ntfy/webview.js | 14 ++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 recipes/ntfy/icon.svg create mode 100644 recipes/ntfy/index.js create mode 100644 recipes/ntfy/package.json create mode 100644 recipes/ntfy/webview.js diff --git a/recipes/ntfy/icon.svg b/recipes/ntfy/icon.svg new file mode 100644 index 0000000..9e5b513 --- /dev/null +++ b/recipes/ntfy/icon.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/recipes/ntfy/index.js b/recipes/ntfy/index.js new file mode 100644 index 0000000..8244b1b --- /dev/null +++ b/recipes/ntfy/index.js @@ -0,0 +1 @@ +module.exports = Ferdium => Ferdium; \ No newline at end of file diff --git a/recipes/ntfy/package.json b/recipes/ntfy/package.json new file mode 100644 index 0000000..76771b0 --- /dev/null +++ b/recipes/ntfy/package.json @@ -0,0 +1,17 @@ +{ + "id": "ntfy", + "name": "ntfy", + "version": "1.0.0", + "license": "MIT", + "aliases": [ + "Notify" + ], + "config": { + "serviceURL": "https://ntfy.sh/app", + "hasCustomUrl": true, + "message": "ntfy lets you send push notifications to your phone or desktop via scripts from any computer, using simple HTTP PUT or POST requests.", + "hasNotificationSound": true, + "hasDirectMessages": true, + "hasIndirectMessages": false + } +} diff --git a/recipes/ntfy/webview.js b/recipes/ntfy/webview.js new file mode 100644 index 0000000..45b8d2d --- /dev/null +++ b/recipes/ntfy/webview.js @@ -0,0 +1,14 @@ +module.exports = (Ferdium) => { + const getMessages = () => { + let msgRaw = document.title.match(/\(\d*\)/); + let messages = 0; + + if (msgRaw) { + messages = Ferdium.safeParseInt(msgRaw[0].slice(1)); + } + + Ferdium.setBadge(messages, 0); + } + + Ferdium.loop(getMessages); +}; \ No newline at end of file -- cgit v1.2.3-54-g00ecf