diff options
author | Jalil Salamé <60845989+jalil-salame@users.noreply.github.com> | 2023-05-12 06:27:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-12 09:57:24 +0530 |
commit | e2b06809981fca02ef6337b6ac0a5c28ec70a996 (patch) | |
tree | 0d2834f5b1233f52e98058208244a433468d4dc3 /recipes/elk/webview.js | |
parent | add miroslavpejic85 as a contributor for code (#361) (diff) | |
download | ferdium-recipes-e2b06809981fca02ef6337b6ac0a5c28ec70a996.tar.gz ferdium-recipes-e2b06809981fca02ef6337b6ac0a5c28ec70a996.tar.zst ferdium-recipes-e2b06809981fca02ef6337b6ac0a5c28ec70a996.zip |
Add Elk recipe (#358)
Elk is a modern Mastodon web client, you can check it out at https://elk.zone/
Diffstat (limited to 'recipes/elk/webview.js')
-rw-r--r-- | recipes/elk/webview.js | 23 |
1 files changed, 23 insertions, 0 deletions
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 @@ | |||
1 | const _path = _interopRequireDefault(require('path')); | ||
2 | |||
3 | function _interopRequireDefault(obj) { | ||
4 | return obj && obj.__esModule ? obj : { default: obj }; | ||
5 | } | ||
6 | |||
7 | module.exports = (Ferdium) => { | ||
8 | // Inject css | ||
9 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
10 | |||
11 | // Get notifications | ||
12 | Ferdium.loop(() => { | ||
13 | const notifications = document.querySelectorAll("[href$=notifications]").item(0); | ||
14 | // Null if not present | ||
15 | if (!notifications) { | ||
16 | return; | ||
17 | } | ||
18 | // Assume first element contains the number of notifications | ||
19 | let parsedValue = Ferdium.safeParseInt(notifications.outerText); | ||
20 | // Set to parsed value | ||
21 | Ferdium.setBadge(parsedValue); | ||
22 | }); | ||
23 | } | ||