diff options
Diffstat (limited to 'recipes/ms-planner/webview.js')
-rw-r--r-- | recipes/ms-planner/webview.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/recipes/ms-planner/webview.js b/recipes/ms-planner/webview.js new file mode 100644 index 0000000..4dd73fd --- /dev/null +++ b/recipes/ms-planner/webview.js | |||
@@ -0,0 +1,40 @@ | |||
1 | const path = require('path'); | ||
2 | |||
3 | setTimeout(() => { | ||
4 | const elem = document.querySelector('.landing-title.version-title'); | ||
5 | if (elem && elem.textContent.toLowerCase().includes('google chrome')) { | ||
6 | window.FerdiumAPI.clearCache(); | ||
7 | window.location.reload(); | ||
8 | } | ||
9 | }, 1000); | ||
10 | |||
11 | const isMutedIcon = element => | ||
12 | element.parentElement.parentElement.querySelectorAll('*[data-icon="muted"]') | ||
13 | .length > 0; | ||
14 | |||
15 | const isPinnedIcon = element => element.classList.contains('_1EFSv'); | ||
16 | |||
17 | module.exports = Ferdium => { | ||
18 | const getMessages = function getMessages() { | ||
19 | const elements = document.querySelectorAll( | ||
20 | '.CxUIE, .unread, ._0LqQ, .m61XR .ZKn2B, .VOr2j, ._1V5O7 ._2vfYK, html[dir] ._23LrM, ._1pJ9J:not(._2XH9R)', | ||
21 | ); | ||
22 | let count = 0; | ||
23 | |||
24 | for (const element of elements) { | ||
25 | try { | ||
26 | // originalLog(isMutedIcon(elements[i]), isPinnedIcon(elements[i])); | ||
27 | if (!isMutedIcon(element) && !isPinnedIcon(element)) { | ||
28 | count += 1; | ||
29 | } | ||
30 | } catch { | ||
31 | // nope; | ||
32 | } | ||
33 | } | ||
34 | |||
35 | Ferdium.setBadge(count); | ||
36 | }; | ||
37 | |||
38 | Ferdium.injectCSS(path.join(__dirname, 'service.css')); | ||
39 | Ferdium.loop(getMessages); | ||
40 | }; | ||