diff options
author | 2021-10-23 19:13:55 +0500 | |
---|---|---|
committer | 2021-10-23 19:43:55 +0530 | |
commit | 591a9a4ca229dcda6e54d4e24f79dfef14d0acc5 (patch) | |
tree | 8676eb01fe567fb96c8220459746d55cc3dbf12a /recipes/telegram | |
parent | fix for #286 with fallback (#738) (diff) | |
download | ferdium-recipes-591a9a4ca229dcda6e54d4e24f79dfef14d0acc5.tar.gz ferdium-recipes-591a9a4ca229dcda6e54d4e24f79dfef14d0acc5.tar.zst ferdium-recipes-591a9a4ca229dcda6e54d4e24f79dfef14d0acc5.zip |
Add setDialogTitle feature to api, WhatsApp and Telegram (#750)
Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'recipes/telegram')
-rw-r--r-- | recipes/telegram/package.json | 2 | ||||
-rw-r--r-- | recipes/telegram/webview.js | 23 |
2 files changed, 18 insertions, 7 deletions
diff --git a/recipes/telegram/package.json b/recipes/telegram/package.json index adb6de6..beda3c3 100644 --- a/recipes/telegram/package.json +++ b/recipes/telegram/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "telegram", | 2 | "id": "telegram", |
3 | "name": "Telegram", | 3 | "name": "Telegram", |
4 | "version": "3.2.2", | 4 | "version": "3.2.3", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://web.telegram.org", | 7 | "serviceURL": "https://web.telegram.org", |
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 | ||
9 | module.exports = Ferdi => { | 9 | module.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 | }; |