aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/misskey
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/misskey')
-rw-r--r--recipes/misskey/index.js54
-rw-r--r--recipes/misskey/webview.js6
2 files changed, 32 insertions, 28 deletions
diff --git a/recipes/misskey/index.js b/recipes/misskey/index.js
index 3f51bf9..5805c37 100644
--- a/recipes/misskey/index.js
+++ b/recipes/misskey/index.js
@@ -1,28 +1,30 @@
1module.exports = Ferdi => class Misskey extends Ferdi { 1module.exports = Ferdi =>
2 constructor(...args) { 2 class Misskey extends Ferdi {
3 let _temp; 3 constructor(...args) {
4 return _temp = super(...args), this.events = { 4 let _temp;
5 }, _temp; 5 // eslint-disable-next-line constructor-super
6 } 6 return (_temp = super(...args)), (this.events = {}), _temp;
7 }
7 8
8 async validateUrl(url) { 9 async validateUrl(url) {
9 try { 10 try {
10 const res = await window.fetch(`${url}/api/stats`, { 11 const res = await window.fetch(`${url}/api/stats`, {
11 method: 'POST', 12 method: 'POST',
12 headers: { 13 headers: {
13 'Content-Type': 'application/json', 14 'Content-Type': 'application/json',
14 }, 15 },
15 }); 16 });
16 const data = await res.json(); 17 const data = await res.json();
17 // check any field in API response 18 // check any field in API response
18 return [ 19 return [
19 'originalUsersCount', 'usersCount', 'notesCount', 'originalNotesCount' 20 'originalUsersCount',
20 ].reduce((r, key) => ( 21 'usersCount',
21 r && Object.hasOwnProperty.call(data, 'uri') 22 'notesCount',
22 ), true); 23 'originalNotesCount',
23 } catch (err) { 24 ].reduce(r => r && Object.hasOwnProperty.call(data, 'uri'), true);
24 console.error(err); 25 } catch (err) {
26 console.error(err);
27 }
28 return false;
25 } 29 }
26 return false; 30 };
27 }
28};
diff --git a/recipes/misskey/webview.js b/recipes/misskey/webview.js
index c174266..65fa237 100644
--- a/recipes/misskey/webview.js
+++ b/recipes/misskey/webview.js
@@ -1,7 +1,9 @@
1module.exports = (Ferdi) => { 1module.exports = Ferdi => {
2 const getMessages = () => { 2 const getMessages = () => {
3 // check notification badge for Ferdi badge 3 // check notification badge for Ferdi badge
4 let hasNotification = !!document.querySelector('#app div.notifications > button > i.circle'); 4 let hasNotification = !!document.querySelector(
5 '#app div.notifications > button > i.circle',
6 );
5 Ferdi.setBadge(0, hasNotification ? 1 : 0); 7 Ferdi.setBadge(0, hasNotification ? 1 : 0);
6 }; 8 };
7 9