From 4b3385094ba8a89247be421c81603a8dcbc99753 Mon Sep 17 00:00:00 2001 From: Vijay Aravamudhan Date: Sun, 12 Sep 2021 13:08:33 +0530 Subject: New recipe: 'misskey' (#693) --- recipes/misskey/icon.svg | 144 +++++++++++++++++++++++++++++++++++++++++++ recipes/misskey/index.js | 28 +++++++++ recipes/misskey/package.json | 13 ++++ recipes/misskey/webview.js | 9 +++ 4 files changed, 194 insertions(+) create mode 100644 recipes/misskey/icon.svg create mode 100644 recipes/misskey/index.js create mode 100644 recipes/misskey/package.json create mode 100644 recipes/misskey/webview.js (limited to 'recipes') diff --git a/recipes/misskey/icon.svg b/recipes/misskey/icon.svg new file mode 100644 index 0000000..2f728ed --- /dev/null +++ b/recipes/misskey/icon.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/recipes/misskey/index.js b/recipes/misskey/index.js new file mode 100644 index 0000000..3f51bf9 --- /dev/null +++ b/recipes/misskey/index.js @@ -0,0 +1,28 @@ +module.exports = Ferdi => class Misskey extends Ferdi { + constructor(...args) { + let _temp; + return _temp = super(...args), this.events = { + }, _temp; + } + + async validateUrl(url) { + try { + const res = await window.fetch(`${url}/api/stats`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + }); + const data = await res.json(); + // check any field in API response + return [ + 'originalUsersCount', 'usersCount', 'notesCount', 'originalNotesCount' + ].reduce((r, key) => ( + r && Object.hasOwnProperty.call(data, 'uri') + ), true); + } catch (err) { + console.error(err); + } + return false; + } +}; diff --git a/recipes/misskey/package.json b/recipes/misskey/package.json new file mode 100644 index 0000000..66bdd3c --- /dev/null +++ b/recipes/misskey/package.json @@ -0,0 +1,13 @@ +{ + "id": "misskey", + "name": "Misskey", + "version": "1.0.0", + "license": "MIT", + "repository": "https://github.com/sharkpp/franz-recipe-misskey", + "config": { + "serviceURL": "https://{teamId}", + "hasTeamId": true, + "hasNotificationSound": true, + "message": "Please enter the instance address of Misskey in the team name input box." + } +} diff --git a/recipes/misskey/webview.js b/recipes/misskey/webview.js new file mode 100644 index 0000000..b024ce1 --- /dev/null +++ b/recipes/misskey/webview.js @@ -0,0 +1,9 @@ +module.exports = (Ferdi) => { + const getMessages = function getMessages() { + // check notification badge for Ferdi badge + let hasNotification = !!document.querySelector('#app div.notifications > button > i.circle'); + Ferdi.setBadge(0, hasNotification ? 1 : 0); + }; + + Ferdi.loop(getMessages); +}; -- cgit v1.2.3-54-g00ecf