aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/telegram/webview.js
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/telegram/webview.js')
-rw-r--r--recipes/telegram/webview.js23
1 files changed, 17 insertions, 6 deletions
diff --git a/recipes/telegram/webview.js b/recipes/telegram/webview.js
index 358bdaa..7d2c8e3 100644
--- a/recipes/telegram/webview.js
+++ b/recipes/telegram/webview.js
@@ -8,25 +8,36 @@ function _interopRequireDefault(obj) {
8 8
9module.exports = Ferdi => { 9module.exports = Ferdi => {
10 const getMessages = () => { 10 const getMessages = () => {
11 let count = 0; 11 let direct = 0;
12 let count_sec = 0; 12 let indirect = 0;
13 const elements = document.querySelectorAll('.rp'); 13 const elements = document.querySelectorAll('.rp');
14 for (const element of elements) { 14 for (const element of elements) {
15 const subtitleBadge = element.querySelector('.dialog-subtitle-badge'); 15 const subtitleBadge = element.querySelector('.dialog-subtitle-badge');
16 if (subtitleBadge) { 16 if (subtitleBadge) {
17 const parsedValue = Ferdi.safeParseInt(subtitleBadge.textContent); 17 const parsedValue = Ferdi.safeParseInt(subtitleBadge.textContent);
18 if (element.dataset.peerId > 0) { 18 if (element.dataset.peerId > 0) {
19 count += parsedValue; 19 direct += parsedValue;
20 } else { 20 } else {
21 count_sec += parsedValue; 21 indirect += parsedValue;
22 } 22 }
23 } 23 }
24 } 24 }
25 25
26 Ferdi.setBadge(count, count_sec); 26 Ferdi.setBadge(direct, indirect);
27 }; 27 };
28 28
29 Ferdi.loop(getMessages); 29 const getActiveDialogTitle = () => {
30 const element = document.querySelector('.top .peer-title');
31
32 Ferdi.setDialogTitle(element ? element.textContent : '');
33 };
34
35 const loopFunc = () => {
36 getMessages();
37 getActiveDialogTitle();
38 };
39
40 Ferdi.loop(loopFunc);
30 41
31 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css')); 42 Ferdi.injectCSS(_path.default.join(__dirname, 'service.css'));
32}; 43};