diff options
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 | } | ||