diff options
author | 2021-10-31 15:50:10 +0100 | |
---|---|---|
committer | 2021-10-31 15:50:10 +0100 | |
commit | dc3fba527eb128ce9b57426a51b59385c00ff694 (patch) | |
tree | 21eea7f9fdaaa5f2ef67b14eda4e99877e6582bd /recipes/moodle/webview.js | |
parent | chore: upgrade 'nodejs' to '16.13.0' (diff) | |
download | ferdium-recipes-dc3fba527eb128ce9b57426a51b59385c00ff694.tar.gz ferdium-recipes-dc3fba527eb128ce9b57426a51b59385c00ff694.tar.zst ferdium-recipes-dc3fba527eb128ce9b57426a51b59385c00ff694.zip |
Add moodle recipe
Diffstat (limited to 'recipes/moodle/webview.js')
-rw-r--r-- | recipes/moodle/webview.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/recipes/moodle/webview.js b/recipes/moodle/webview.js new file mode 100644 index 0000000..ba19f3f --- /dev/null +++ b/recipes/moodle/webview.js | |||
@@ -0,0 +1,18 @@ | |||
1 | var _path = _interopRequireDefault(require('path')); | ||
2 | |||
3 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
4 | |||
5 | module.exports = Ferdi => { | ||
6 | const getMessages = () => { | ||
7 | const elements = [...document.querySelectorAll('[data-region="count-container"]')]; | ||
8 | const messages = elements.reduce( | ||
9 | ((count, item) => count + Number(item.textContent)), | ||
10 | 0 | ||
11 | ); | ||
12 | |||
13 | Ferdi.setBadge(messages, 0); | ||
14 | }; | ||
15 | Ferdi.loop(getMessages); | ||
16 | |||
17 | Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); | ||
18 | }; | ||