aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/elk/webview.js
diff options
context:
space:
mode:
authorLibravatar Jalil Salamé <60845989+jalil-salame@users.noreply.github.com>2023-05-12 06:27:24 +0200
committerLibravatar GitHub <noreply@github.com>2023-05-12 09:57:24 +0530
commite2b06809981fca02ef6337b6ac0a5c28ec70a996 (patch)
tree0d2834f5b1233f52e98058208244a433468d4dc3 /recipes/elk/webview.js
parentadd miroslavpejic85 as a contributor for code (#361) (diff)
downloadferdium-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.js23
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 @@
1const _path = _interopRequireDefault(require('path'));
2
3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
6
7module.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}