diff options
Diffstat (limited to 'recipes')
36 files changed, 225 insertions, 162 deletions
diff --git a/recipes/NewsBlur/webview.js b/recipes/NewsBlur/webview.js index 7e19dff..23607bd 100644 --- a/recipes/NewsBlur/webview.js +++ b/recipes/NewsBlur/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/basecamp/webview.js b/recipes/basecamp/webview.js index e7b7dde..16eced3 100644 --- a/recipes/basecamp/webview.js +++ b/recipes/basecamp/webview.js | |||
@@ -1,9 +1,10 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | 1 | const _path = _interopRequireDefault(require('path')); |
2 | 2 | ||
3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 3 | function _interopRequireDefault(obj) { |
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
4 | 6 | ||
5 | module.exports = (Ferdi) => { | 7 | module.exports = Ferdi => { |
6 | let updates = 0; | ||
7 | const modal = document.createElement('div'); | 8 | const modal = document.createElement('div'); |
8 | 9 | ||
9 | const waitFor = (condition, callback) => { | 10 | const waitFor = (condition, callback) => { |
@@ -16,13 +17,11 @@ module.exports = (Ferdi) => { | |||
16 | function showModal(text) { | 17 | function showModal(text) { |
17 | show(modal); | 18 | show(modal); |
18 | modal.querySelector('p').innerHTML = text; | 19 | modal.querySelector('p').innerHTML = text; |
19 | updates += 1; | ||
20 | } | 20 | } |
21 | 21 | ||
22 | function hideModal() { | 22 | function hideModal() { |
23 | hide(modal); | 23 | hide(modal); |
24 | modal.querySelector('p').innerHTML = ''; | 24 | modal.querySelector('p').innerHTML = ''; |
25 | updates -= 1; | ||
26 | } | 25 | } |
27 | 26 | ||
28 | // Replace window.alert to hide alerts in Ferdi | 27 | // Replace window.alert to hide alerts in Ferdi |
@@ -41,11 +40,19 @@ module.exports = (Ferdi) => { | |||
41 | } | 40 | } |
42 | 41 | ||
43 | modal.id = 'franz-modal'; | 42 | modal.id = 'franz-modal'; |
44 | modal.innerHTML = '<div class="modal-content"><span class="close">×</span><p></p></div>'; | 43 | modal.innerHTML = |
44 | '<div class="modal-content"><span class="close">×</span><p></p></div>'; | ||
45 | modal.querySelector('.close').addEventListener('click', hideModal); | 45 | modal.querySelector('.close').addEventListener('click', hideModal); |
46 | waitFor(() => document.body, () => document.body.appendChild(modal)); | 46 | waitFor( |
47 | 47 | () => document.body, | |
48 | document.addEventListener('keydown', (e) => { if (e.keyCode === 27) { hideModal(); } }); | 48 | () => document.body.appendChild(modal), |
49 | ); | ||
50 | |||
51 | document.addEventListener('keydown', e => { | ||
52 | if (e.key === 'Escape') { | ||
53 | hideModal(); | ||
54 | } | ||
55 | }); | ||
49 | 56 | ||
50 | Ferdi.injectCSS(_path.default.join(__dirname, 'css', 'modal.css')); | 57 | Ferdi.injectCSS(_path.default.join(__dirname, 'css', 'modal.css')); |
51 | }; | 58 | }; |
diff --git a/recipes/box/webview.js b/recipes/box/webview.js index 7e19dff..23607bd 100644 --- a/recipes/box/webview.js +++ b/recipes/box/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/devRant/index.js b/recipes/devRant/index.js index 7e19dff..23607bd 100644 --- a/recipes/devRant/index.js +++ b/recipes/devRant/index.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/devdocs/webview.js b/recipes/devdocs/webview.js index 7e19dff..23607bd 100644 --- a/recipes/devdocs/webview.js +++ b/recipes/devdocs/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/easy-redmine/webview.js b/recipes/easy-redmine/webview.js index 7e19dff..23607bd 100644 --- a/recipes/easy-redmine/webview.js +++ b/recipes/easy-redmine/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/feedbin/webview.js b/recipes/feedbin/webview.js index 5c08892..197814e 100644 --- a/recipes/feedbin/webview.js +++ b/recipes/feedbin/webview.js | |||
@@ -1,8 +1,9 @@ | |||
1 | module.exports = (Ferdi) => { | 1 | module.exports = Ferdi => { |
2 | const getMessages = () => { | 2 | const getMessages = () => { |
3 | // eslint-disable-next-line no-undef | ||
3 | const count = feedbin.count_data.unread_entries.length || 0; | 4 | const count = feedbin.count_data.unread_entries.length || 0; |
4 | Ferdi.setBadge(count); | 5 | Ferdi.setBadge(count); |
5 | } | 6 | }; |
6 | 7 | ||
7 | Ferdi.loop(getMessages); | 8 | Ferdi.loop(getMessages); |
8 | }; | 9 | }; |
diff --git a/recipes/figma/webview.js b/recipes/figma/webview.js index 7e19dff..23607bd 100644 --- a/recipes/figma/webview.js +++ b/recipes/figma/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/franz-custom-website/index.js b/recipes/franz-custom-website/index.js index c0f91cb..6e4f228 100644 --- a/recipes/franz-custom-website/index.js +++ b/recipes/franz-custom-website/index.js | |||
@@ -1,5 +1,6 @@ | |||
1 | module.exports = Ferdi => class CustomWebsite extends Ferdi { | 1 | module.exports = Ferdi => |
2 | async validateUrl(url) { | 2 | class CustomWebsite extends Ferdi { |
3 | return true; | 3 | async validateUrl() { |
4 | } | 4 | return true; |
5 | }; | 5 | } |
6 | }; | ||
diff --git a/recipes/franz-custom-website/webview.js b/recipes/franz-custom-website/webview.js index ca6a9f7..9eec086 100644 --- a/recipes/franz-custom-website/webview.js +++ b/recipes/franz-custom-website/webview.js | |||
@@ -1,6 +1,8 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | 1 | const _path = _interopRequireDefault(require('path')); |
2 | 2 | ||
3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 3 | function _interopRequireDefault(obj) { |
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
4 | 6 | ||
5 | module.exports = Ferdi => { | 7 | module.exports = Ferdi => { |
6 | Ferdi.injectCSS(_path.default.join(__dirname, 'style.css')); | 8 | Ferdi.injectCSS(_path.default.join(__dirname, 'style.css')); |
diff --git a/recipes/google-voice/webview.js b/recipes/google-voice/webview.js index 7cada87..eb3004d 100644 --- a/recipes/google-voice/webview.js +++ b/recipes/google-voice/webview.js | |||
@@ -9,16 +9,23 @@ module.exports = Ferdi => { | |||
9 | let count; | 9 | let count; |
10 | 10 | ||
11 | if (el) { | 11 | if (el) { |
12 | // eslint-disable-next-line no-useless-escape | ||
12 | count = Ferdi.safeParseInt(el.innerHTML.replace(/[\(\) ]/gi, '')); | 13 | count = Ferdi.safeParseInt(el.innerHTML.replace(/[\(\) ]/gi, '')); |
13 | } else { | 14 | } else { |
14 | const count_messages = parseQuery('gv-nav-tab[tooltip="Messages"] div[aria-label="Unread count"]'); | 15 | const count_messages = parseQuery( |
15 | const count_calls = parseQuery('gv-nav-tab[tooltip="Calls"] div[aria-label="Unread count"]'); | 16 | 'gv-nav-tab[tooltip="Messages"] div[aria-label="Unread count"]', |
16 | const count_voicemails = parseQuery('gv-nav-tab[tooltip="Voicemail"] div[aria-label="Unread count"]'); | 17 | ); |
18 | const count_calls = parseQuery( | ||
19 | 'gv-nav-tab[tooltip="Calls"] div[aria-label="Unread count"]', | ||
20 | ); | ||
21 | const count_voicemails = parseQuery( | ||
22 | 'gv-nav-tab[tooltip="Voicemail"] div[aria-label="Unread count"]', | ||
23 | ); | ||
17 | count = count_messages + count_calls + count_voicemails; | 24 | count = count_messages + count_calls + count_voicemails; |
18 | } | 25 | } |
19 | 26 | ||
20 | Ferdi.setBadge(count); | 27 | Ferdi.setBadge(count); |
21 | } | 28 | }; |
22 | 29 | ||
23 | Ferdi.loop(getMessages); | 30 | Ferdi.loop(getMessages); |
24 | }; | 31 | }; |
diff --git a/recipes/googlecalendar/webview-unsafe.js b/recipes/googlecalendar/webview-unsafe.js index c47f572..54a7338 100644 --- a/recipes/googlecalendar/webview-unsafe.js +++ b/recipes/googlecalendar/webview-unsafe.js | |||
@@ -26,7 +26,8 @@ const hideModal = () => { | |||
26 | const createModal = () => { | 26 | const createModal = () => { |
27 | const modalDialog = document.createElement('div'); | 27 | const modalDialog = document.createElement('div'); |
28 | modalDialog.setAttribute('id', 'franz-modal'); | 28 | modalDialog.setAttribute('id', 'franz-modal'); |
29 | modalDialog.innerHTML = '<div class="modal-content"><span class="close">×</span><p></p></div>'; | 29 | modalDialog.innerHTML = |
30 | '<div class="modal-content"><span class="close">×</span><p></p></div>'; | ||
30 | modalDialog.querySelector('.close').addEventListener('click', hideModal); | 31 | modalDialog.querySelector('.close').addEventListener('click', hideModal); |
31 | 32 | ||
32 | return modalDialog; | 33 | return modalDialog; |
@@ -35,5 +36,11 @@ const createModal = () => { | |||
35 | window.alert = showModal; | 36 | window.alert = showModal; |
36 | 37 | ||
37 | modal = createModal(); | 38 | modal = createModal(); |
38 | waitFor(() => document.body, () => document.body.appendChild(modal)); | 39 | waitFor( |
39 | document.addEventListener('keydown', event => event.keyCode === 27 && hideModal()); | 40 | () => document.body, |
41 | () => document.body.appendChild(modal), | ||
42 | ); | ||
43 | document.addEventListener( | ||
44 | 'keydown', | ||
45 | event => event.key === 'Escape' && hideModal(), | ||
46 | ); | ||
diff --git a/recipes/iCloud/webview.js b/recipes/iCloud/webview.js index 7e19dff..23607bd 100644 --- a/recipes/iCloud/webview.js +++ b/recipes/iCloud/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/icloud-reminders/webview.js b/recipes/icloud-reminders/webview.js index 7e19dff..23607bd 100644 --- a/recipes/icloud-reminders/webview.js +++ b/recipes/icloud-reminders/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/keybase.io/webview.js b/recipes/keybase.io/webview.js index 7e19dff..23607bd 100644 --- a/recipes/keybase.io/webview.js +++ b/recipes/keybase.io/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/line-me/webview.js b/recipes/line-me/webview.js index 7e19dff..23607bd 100644 --- a/recipes/line-me/webview.js +++ b/recipes/line-me/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/mastodon/index.js b/recipes/mastodon/index.js index 1dd93cc..9be0938 100644 --- a/recipes/mastodon/index.js +++ b/recipes/mastodon/index.js | |||
@@ -1,9 +1,9 @@ | |||
1 | module.exports = (Ferdi) => { | 1 | module.exports = Ferdi => { |
2 | class Mastodon extends Ferdi { | 2 | class Mastodon extends Ferdi { |
3 | validateServer(URL) { | 3 | validateServer(URL) { |
4 | const api = `${URL}`; | 4 | const api = `${URL}`; |
5 | return new Promise((resolve, reject) => { | 5 | return new Promise((resolve, reject) => { |
6 | $.get(api, (resp) => { | 6 | $.get(api, () => { |
7 | resolve(); | 7 | resolve(); |
8 | }).fail(reject); | 8 | }).fail(reject); |
9 | }); | 9 | }); |
diff --git a/recipes/mastodon/webview.js b/recipes/mastodon/webview.js index 4b450a1..8fb448f 100644 --- a/recipes/mastodon/webview.js +++ b/recipes/mastodon/webview.js | |||
@@ -1,11 +1,11 @@ | |||
1 | module.exports = (Ferdi) => { | 1 | module.exports = Ferdi => { |
2 | let latestStatement = $('.status time').attr('datetime'); | 2 | let latestStatement = $('.status time').attr('datetime'); |
3 | let latestNotify = $($('.notification__message span').get(0)).text(); | 3 | let latestNotify = $($('.notification__message span').get(0)).text(); |
4 | 4 | ||
5 | $($('div.column div.scrollable').get(0)).on('scroll', (ev) => { | 5 | $($('div.column div.scrollable').get(0)).on('scroll', () => { |
6 | latestStatement = $('.status time').attr('datetime'); | 6 | latestStatement = $('.status time').attr('datetime'); |
7 | }); | 7 | }); |
8 | $($('div.column div.scrollable').get(1)).on('scroll', (ev) => { | 8 | $($('div.column div.scrollable').get(1)).on('scroll', () => { |
9 | latestNotify = $($('.notification__message span').get(0)).text(); | 9 | latestNotify = $($('.notification__message span').get(0)).text(); |
10 | }); | 10 | }); |
11 | 11 | ||
@@ -22,7 +22,7 @@ module.exports = (Ferdi) => { | |||
22 | } | 22 | } |
23 | 23 | ||
24 | Ferdi.setBadge(reply, unread); | 24 | Ferdi.setBadge(reply, unread); |
25 | } | 25 | }; |
26 | 26 | ||
27 | Ferdi.loop(getMessages); | 27 | Ferdi.loop(getMessages); |
28 | }; | 28 | }; |
diff --git a/recipes/messenger/webview.js b/recipes/messenger/webview.js index 954f843..5b2f2ad 100644 --- a/recipes/messenger/webview.js +++ b/recipes/messenger/webview.js | |||
@@ -8,18 +8,23 @@ module.exports = Ferdi => { | |||
8 | * Notification case for group chats, workaround by tamas646 | 8 | * Notification case for group chats, workaround by tamas646 |
9 | * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-783409154 | 9 | * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-783409154 |
10 | */ | 10 | */ |
11 | if (isNotification)Â { | 11 | if (isNotification) { |
12 | count = Ferdi.safeParseInt(/^\((\d+)\)/.exec(document.title)[1]); | 12 | count = Ferdi.safeParseInt(/^\((\d+)\)/.exec(document.title)[1]); |
13 | } else { | 13 | } else { |
14 | /* | 14 | /* |
15 | * Notification case for direct messages, workaround by manavortex | 15 | * Notification case for direct messages, workaround by manavortex |
16 | * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-846611765 | 16 | * see https://github.com/getferdi/ferdi/issues/1113#issuecomment-846611765 |
17 | */ | 17 | */ |
18 | count = document.querySelectorAll('._5fx8:not(._569x),._1ht3:not(._569x)').length; | 18 | count = document.querySelectorAll( |
19 | '._5fx8:not(._569x),._1ht3:not(._569x)', | ||
20 | ).length; | ||
19 | if (count === 0) { | 21 | if (count === 0) { |
20 | count = document.querySelectorAll('.pq6dq46d.is6700om.qu0x051f.esr5mh6w.e9989ue4.r7d6kgcz.s45kfl79.emlxlaya.bkmhp75w.spb7xbtv.cyypbtt7.fwizqjfa').length; | 22 | count = document.querySelectorAll( |
23 | '.pq6dq46d.is6700om.qu0x051f.esr5mh6w.e9989ue4.r7d6kgcz.s45kfl79.emlxlaya.bkmhp75w.spb7xbtv.cyypbtt7.fwizqjfa', | ||
24 | ).length; | ||
21 | } | 25 | } |
22 | if (count === 0) { // might be obsolete, not sure - never ran into this case | 26 | if (count === 0) { |
27 | // might be obsolete, not sure - never ran into this case | ||
23 | count = document.querySelectorAll('[aria-label="Mark as read"]').length; | 28 | count = document.querySelectorAll('[aria-label="Mark as read"]').length; |
24 | } | 29 | } |
25 | } | 30 | } |
@@ -36,19 +41,25 @@ module.exports = Ferdi => { | |||
36 | 41 | ||
37 | Ferdi.loop(getMessages); | 42 | Ferdi.loop(getMessages); |
38 | 43 | ||
39 | localStorage.setItem('_cs_desktopNotifsEnabled', JSON.stringify({ | 44 | localStorage.setItem( |
40 | __t: new Date().getTime(), | 45 | '_cs_desktopNotifsEnabled', |
41 | __v: true, | 46 | JSON.stringify({ |
42 | })); | 47 | __t: new Date().getTime(), |
48 | __v: true, | ||
49 | }), | ||
50 | ); | ||
43 | 51 | ||
44 | if (typeof Ferdi.onNotify === 'function') { | 52 | if (typeof Ferdi.onNotify === 'function') { |
45 | Ferdi.onNotify(notification => { | 53 | Ferdi.onNotify(notification => { |
46 | if (typeof notification.title !== 'string') { | 54 | if (typeof notification.title !== 'string') { |
47 | notification.title = ((notification.title.props || {}).content || [])[0] || 'Messenger'; | 55 | notification.title = |
56 | ((notification.title.props || {}).content || [])[0] || 'Messenger'; | ||
48 | } | 57 | } |
49 | 58 | ||
50 | if (typeof notification.options.body !== 'string') { | 59 | if (typeof notification.options.body !== 'string') { |
51 | notification.options.body = (((notification.options.body || {}).props || {}).content || [])[0] || ''; | 60 | notification.options.body = |
61 | (((notification.options.body || {}).props || {}).content || [])[0] || | ||
62 | ''; | ||
52 | } | 63 | } |
53 | 64 | ||
54 | return notification; | 65 | return notification; |
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 @@ | |||
1 | module.exports = Ferdi => class Misskey extends Ferdi { | 1 | module.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 @@ | |||
1 | module.exports = (Ferdi) => { | 1 | module.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 | ||
diff --git a/recipes/netatmo-energy/webview.js b/recipes/netatmo-energy/webview.js index 7e19dff..23607bd 100644 --- a/recipes/netatmo-energy/webview.js +++ b/recipes/netatmo-energy/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/odoo/webview.js b/recipes/odoo/webview.js index 8f02c8f..453b3fc 100644 --- a/recipes/odoo/webview.js +++ b/recipes/odoo/webview.js | |||
@@ -1,4 +1,9 @@ | |||
1 | module.exports = (Ferdi) => { | 1 | const _path = _interopRequireDefault(require('path')); |
2 | 2 | ||
3 | Ferdi.injectCSS(_path.default.join(__dirname, "service.css")); | 3 | function _interopRequireDefault(obj) { |
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
6 | |||
7 | module.exports = Ferdi => { | ||
8 | Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
4 | }; | 9 | }; |
diff --git a/recipes/paymo/webview.js b/recipes/paymo/webview.js index 7e19dff..23607bd 100644 --- a/recipes/paymo/webview.js +++ b/recipes/paymo/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/pinterest/webview.js b/recipes/pinterest/webview.js index 7e19dff..23607bd 100644 --- a/recipes/pinterest/webview.js +++ b/recipes/pinterest/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/plan/webview.js b/recipes/plan/webview.js index 7e19dff..23607bd 100644 --- a/recipes/plan/webview.js +++ b/recipes/plan/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/pleroma/webview.js b/recipes/pleroma/webview.js index da76955..2ba184e 100644 --- a/recipes/pleroma/webview.js +++ b/recipes/pleroma/webview.js | |||
@@ -1,6 +1,6 @@ | |||
1 | const titleRegex = /^\((\d+)\)/; | 1 | const titleRegex = /^\((\d+)\)/; |
2 | 2 | ||
3 | const getJson = async (relativeUri) => { | 3 | const getJson = async relativeUri => { |
4 | const req = await window.fetch(`${window.origin}${relativeUri}`, { | 4 | const req = await window.fetch(`${window.origin}${relativeUri}`, { |
5 | Accept: 'application/json', | 5 | Accept: 'application/json', |
6 | }); | 6 | }); |
@@ -8,10 +8,11 @@ const getJson = async (relativeUri) => { | |||
8 | }; | 8 | }; |
9 | 9 | ||
10 | const getInstanceConfig = async () => { | 10 | const getInstanceConfig = async () => { |
11 | const origin = window.origin; | ||
12 | const staticConfig = await getJson('/static/config.json'); | 11 | const staticConfig = await getJson('/static/config.json'); |
13 | try { | 12 | try { |
14 | const frontendConfig = await getJson('/api/pleroma/frontend_configurations'); | 13 | const frontendConfig = await getJson( |
14 | '/api/pleroma/frontend_configurations', | ||
15 | ); | ||
15 | const pleromaFeConfig = frontendConfig.pleroma_fe || {}; | 16 | const pleromaFeConfig = frontendConfig.pleroma_fe || {}; |
16 | return { ...staticConfig, ...pleromaFeConfig }; | 17 | return { ...staticConfig, ...pleromaFeConfig }; |
17 | } catch (e) { | 18 | } catch (e) { |
@@ -33,8 +34,12 @@ const getInstanceLogo = async () => { | |||
33 | logoMask: config.logoMask, | 34 | logoMask: config.logoMask, |
34 | }); | 35 | }); |
35 | }); | 36 | }); |
36 | img.addEventListener('error', (event) => { | 37 | img.addEventListener('error', event => { |
37 | reject(new Error(`${event.type} error loading ${config.logo}: ${event.message}`)); | 38 | reject( |
39 | new Error( | ||
40 | `${event.type} error loading ${config.logo}: ${event.message}`, | ||
41 | ), | ||
42 | ); | ||
38 | }); | 43 | }); |
39 | img.src = `${origin}${config.logo}`; | 44 | img.src = `${origin}${config.logo}`; |
40 | }); | 45 | }); |
@@ -146,16 +151,19 @@ module.exports = Ferdi => { | |||
146 | Ferdi.setBadge(directCount); | 151 | Ferdi.setBadge(directCount); |
147 | }; | 152 | }; |
148 | 153 | ||
149 | getInstanceLogo().then(({ logo, logoMask }) => { | 154 | getInstanceLogo().then( |
150 | const updater = new LogoUpdater(logo, logoMask); | 155 | ({ logo, logoMask }) => { |
151 | Ferdi.loop(() => { | 156 | const updater = new LogoUpdater(logo, logoMask); |
152 | getMessages(); | 157 | Ferdi.loop(() => { |
153 | if (updater.update()) { | 158 | getMessages(); |
154 | Ferdi.setAvatarImage(updater.toDataURL()); | 159 | if (updater.update()) { |
155 | } | 160 | Ferdi.setAvatarImage(updater.toDataURL()); |
156 | }); | 161 | } |
157 | }, (e) => { | 162 | }); |
158 | console.log('Failed to load instance logo', e); | 163 | }, |
159 | Ferdi.loop(getMessages); | 164 | e => { |
160 | }); | 165 | console.log('Failed to load instance logo', e); |
166 | Ferdi.loop(getMessages); | ||
167 | }, | ||
168 | ); | ||
161 | }; | 169 | }; |
diff --git a/recipes/pushbullet/index.js b/recipes/pushbullet/index.js index 556cab6..ace403b 100644 --- a/recipes/pushbullet/index.js +++ b/recipes/pushbullet/index.js | |||
@@ -1,16 +1,26 @@ | |||
1 | module.exports = Ferdi => class PushBullet extends Ferdi { | 1 | module.exports = Ferdi => |
2 | constructor(...args) { | 2 | class PushBullet extends Ferdi { |
3 | let _temp; | 3 | constructor(...args) { |
4 | let _temp; | ||
4 | 5 | ||
5 | return _temp = super(...args), this.events = { | 6 | return ( |
6 | 'did-get-redirect-request': '_redirectFix', | 7 | // eslint-disable-next-line constructor-super |
7 | }, _temp; | 8 | (_temp = super(...args)), |
8 | } | 9 | (this.events = { |
10 | 'did-get-redirect-request': '_redirectFix', | ||
11 | }), | ||
12 | _temp | ||
13 | ); | ||
14 | } | ||
9 | 15 | ||
10 | _redirectFix(event) { | 16 | _redirectFix(event) { |
11 | if (event.newURL !== undefined && event.oldURL !== undefined && event.isMainFrame) { | 17 | if ( |
12 | setTimeout(() => this.send('redirect-url', event.newURL), 100); | 18 | event.newURL !== undefined && |
13 | event.preventDefault(); | 19 | event.oldURL !== undefined && |
20 | event.isMainFrame | ||
21 | ) { | ||
22 | setTimeout(() => this.send('redirect-url', event.newURL), 100); | ||
23 | event.preventDefault(); | ||
24 | } | ||
14 | } | 25 | } |
15 | } | 26 | }; |
16 | }; | ||
diff --git a/recipes/reddit/webview.js b/recipes/reddit/webview.js index 327bd89..5095ba1 100644 --- a/recipes/reddit/webview.js +++ b/recipes/reddit/webview.js | |||
@@ -1,10 +1,14 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | 1 | const _path = _interopRequireDefault(require('path')); |
2 | 2 | ||
3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | 3 | function _interopRequireDefault(obj) { |
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
4 | 6 | ||
5 | module.exports = (Ferdi) => { | 7 | module.exports = Ferdi => { |
6 | const getMessages = () => { | 8 | const getMessages = () => { |
7 | const elements = document.querySelectorAll('#HeaderUserActions--Messages > a > span'); | 9 | const elements = document.querySelectorAll( |
10 | '#HeaderUserActions--Messages > a > span', | ||
11 | ); | ||
8 | let count = 0; | 12 | let count = 0; |
9 | 13 | ||
10 | if (elements[0]) { | 14 | if (elements[0]) { |
@@ -15,7 +19,7 @@ module.exports = (Ferdi) => { | |||
15 | }; | 19 | }; |
16 | 20 | ||
17 | if (document.querySelectorAll('.promotedlink').length > 0) { | 21 | if (document.querySelectorAll('.promotedlink').length > 0) { |
18 | document.querySelectorAll('.promotedlink').forEach((sponsoredLink) => { | 22 | document.querySelectorAll('.promotedlink').forEach(sponsoredLink => { |
19 | sponsoredLink.parentElement.parentElement.style.display = 'none'; | 23 | sponsoredLink.parentElement.parentElement.style.display = 'none'; |
20 | }); | 24 | }); |
21 | } | 25 | } |
@@ -25,17 +29,17 @@ module.exports = (Ferdi) => { | |||
25 | // Use CSS to hide Google Ads | 29 | // Use CSS to hide Google Ads |
26 | Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); | 30 | Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); |
27 | 31 | ||
28 | Ferdi.handleDarkMode((isEnabled, config) => { | 32 | Ferdi.handleDarkMode(isEnabled => { |
29 | // Open dropdown menu if not already open | 33 | // Open dropdown menu if not already open |
30 | const menu = document.querySelector('#USER_DROPDOWN_ID'); | 34 | const menu = document.querySelector('#USER_DROPDOWN_ID'); |
31 | if (menu.getAttribute('aria-expanded') === 'false') { | 35 | if (menu && menu.getAttribute('aria-expanded') === 'false') { |
32 | menu.click(); | 36 | menu.click(); |
33 | } | 37 | } |
34 | 38 | ||
35 | setTimeout(() => { | 39 | setTimeout(() => { |
36 | // Check if service is already in right mode | 40 | // Check if service is already in right mode |
37 | const btn = document.querySelector('[role=menu] button button'); | 41 | const btn = document.querySelector('[role=menu] button button'); |
38 | const checked = btn.getAttribute('aria-checked') === 'true'; | 42 | const checked = btn && btn.getAttribute('aria-checked') === 'true'; |
39 | 43 | ||
40 | if ((checked && !isEnabled) || (!checked && isEnabled)) { | 44 | if ((checked && !isEnabled) || (!checked && isEnabled)) { |
41 | // Click the button to switch between modes | 45 | // Click the button to switch between modes |
diff --git a/recipes/redditchat/webview.js b/recipes/redditchat/webview.js index 7000e53..14f7f6c 100644 --- a/recipes/redditchat/webview.js +++ b/recipes/redditchat/webview.js | |||
@@ -1,5 +1,6 @@ | |||
1 | module.exports = Ferdi => { | 1 | module.exports = Ferdi => { |
2 | // Regular expression for (*) or (1), will extract the asterisk or the number | 2 | // Regular expression for (*) or (1), will extract the asterisk or the number |
3 | // eslint-disable-next-line no-useless-escape | ||
3 | const titleRegEx = /^\(([\*\d])\)/; | 4 | const titleRegEx = /^\(([\*\d])\)/; |
4 | const getMessages = function unreadCount() { | 5 | const getMessages = function unreadCount() { |
5 | let directCount = 0; | 6 | let directCount = 0; |
diff --git a/recipes/snapdrop/webview.js b/recipes/snapdrop/webview.js index 22ca24c..23607bd 100644 --- a/recipes/snapdrop/webview.js +++ b/recipes/snapdrop/webview.js | |||
@@ -1 +1 @@ | |||
module.exports = (Ferdi) => {}; | module.exports = Ferdi => Ferdi; | ||
diff --git a/recipes/tawk/webview.js b/recipes/tawk/webview.js index 7e19dff..23607bd 100644 --- a/recipes/tawk/webview.js +++ b/recipes/tawk/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/teamweek/webview.js b/recipes/teamweek/webview.js index 22ca24c..23607bd 100644 --- a/recipes/teamweek/webview.js +++ b/recipes/teamweek/webview.js | |||
@@ -1 +1 @@ | |||
module.exports = (Ferdi) => {}; | module.exports = Ferdi => Ferdi; | ||
diff --git a/recipes/toggl/webview.js b/recipes/toggl/webview.js index 7e19dff..23607bd 100644 --- a/recipes/toggl/webview.js +++ b/recipes/toggl/webview.js | |||
@@ -1,2 +1 @@ | |||
1 | module.exports = Ferdi => { | module.exports = Ferdi => Ferdi; | |
2 | }; | ||
diff --git a/recipes/tweetdeck/index.js b/recipes/tweetdeck/index.js index 3dc2463..f54a64a 100644 --- a/recipes/tweetdeck/index.js +++ b/recipes/tweetdeck/index.js | |||
@@ -1,16 +1,26 @@ | |||
1 | module.exports = Ferdi => class Tweetdeck extends Ferdi { | 1 | module.exports = Ferdi => |
2 | constructor(...args) { | 2 | class Tweetdeck extends Ferdi { |
3 | let _temp; | 3 | constructor(...args) { |
4 | let _temp; | ||
4 | 5 | ||
5 | return _temp = super(...args), this.events = { | 6 | return ( |
6 | 'did-get-redirect-request': '_redirectFix', | 7 | // eslint-disable-next-line constructor-super |
7 | }, _temp; | 8 | (_temp = super(...args)), |
8 | } | 9 | (this.events = { |
10 | 'did-get-redirect-request': '_redirectFix', | ||
11 | }), | ||
12 | _temp | ||
13 | ); | ||
14 | } | ||
9 | 15 | ||
10 | _redirectFix(event) { | 16 | _redirectFix(event) { |
11 | if (event.newURL !== undefined && event.oldURL !== undefined && event.isMainFrame) { | 17 | if ( |
12 | setTimeout(() => this.send('redirect-url', event.newURL), 100); | 18 | event.newURL !== undefined && |
13 | event.preventDefault(); | 19 | event.oldURL !== undefined && |
20 | event.isMainFrame | ||
21 | ) { | ||
22 | setTimeout(() => this.send('redirect-url', event.newURL), 100); | ||
23 | event.preventDefault(); | ||
24 | } | ||
14 | } | 25 | } |
15 | } | 26 | }; |
16 | }; | ||
diff --git a/recipes/zimbra/index.js b/recipes/zimbra/index.js index 1b0a47f..50c3cf2 100644 --- a/recipes/zimbra/index.js +++ b/recipes/zimbra/index.js | |||
@@ -1,5 +1,6 @@ | |||
1 | module.exports = Ferdi => class Zimbra extends Ferdi { | 1 | module.exports = Ferdi => |
2 | async validateUrl(url) { | 2 | class Zimbra extends Ferdi { |
3 | return true; | 3 | async validateUrl() { |
4 | } | 4 | return true; |
5 | }; | 5 | } |
6 | }; | ||