diff options
Diffstat (limited to 'recipes/telegram')
-rw-r--r-- | recipes/telegram/darkmode.css | 190 | ||||
-rw-r--r-- | recipes/telegram/package.json | 2 | ||||
-rw-r--r-- | recipes/telegram/webview.js | 67 |
3 files changed, 58 insertions, 201 deletions
diff --git a/recipes/telegram/darkmode.css b/recipes/telegram/darkmode.css deleted file mode 100644 index 24f415f..0000000 --- a/recipes/telegram/darkmode.css +++ /dev/null | |||
@@ -1,190 +0,0 @@ | |||
1 | /* Copied from: https://github.com/ducfilan/Dark-mode-Franz-Ferdi */ | ||
2 | |||
3 | body, | ||
4 | .modal-content { | ||
5 | color: #bbb !important; | ||
6 | background: rgb(40, 44, 52) !important; | ||
7 | } | ||
8 | |||
9 | a.tg_checkbox { | ||
10 | color: #bbb !important; | ||
11 | } | ||
12 | |||
13 | .im_page_wrap { | ||
14 | /*background color of contentwrapper under header*/ | ||
15 | background-color: rgb(40, 44, 52) !important; | ||
16 | border-left: 1px solid rgb(40, 44, 52) !important; | ||
17 | border-right: 1px solid rgb(40, 44, 52) !important; | ||
18 | border-bottom: 1px solid rgb(40, 44, 52) !important; | ||
19 | box-shadow: none; | ||
20 | } | ||
21 | |||
22 | .im_message_body, | ||
23 | .im_attach, | ||
24 | .im_media_attach, | ||
25 | .im_record, | ||
26 | .im_record_bg, | ||
27 | .im_record:hover, | ||
28 | .im_message_document_thumbed, | ||
29 | .composer_emoji_panel a.composer_emoji_btn { | ||
30 | background: inherit !important; | ||
31 | } | ||
32 | |||
33 | .im_dialog_peer { | ||
34 | /*peer nickname unselected*/ | ||
35 | color: #bbb !important; | ||
36 | } | ||
37 | |||
38 | .contacts_modal_members_list a.contacts_modal_contact { | ||
39 | /*nicknames in contactlist via hamburger menu*/ | ||
40 | color: #bbb; | ||
41 | } | ||
42 | |||
43 | .active a.im_dialog { | ||
44 | /*selected peer */ | ||
45 | background-color: rgb(40, 44, 52) !important; | ||
46 | } | ||
47 | |||
48 | .tg_head_split, | ||
49 | .md_modal_head { | ||
50 | /*page header block*/ | ||
51 | background-color: rgb(40, 44, 52) !important; | ||
52 | } | ||
53 | |||
54 | .dropdown.open .tg_head_btn, | ||
55 | .tg_head_btn:hover { | ||
56 | background: rgb(40, 44, 52) !important; | ||
57 | } | ||
58 | |||
59 | .form-control { | ||
60 | /*input field*/ | ||
61 | background-color: #0e0e0e !important; | ||
62 | color: #bbb !important; | ||
63 | } | ||
64 | |||
65 | .composer_rich_textarea { | ||
66 | background: rgb(40, 44, 52) !important; | ||
67 | border-color: #bbb !important; | ||
68 | } | ||
69 | |||
70 | .im_dialogs_col_wrap { | ||
71 | /*contactlist right border*/ | ||
72 | border-right: 2px solid rgb(40, 44, 52); | ||
73 | } | ||
74 | |||
75 | .im_dialogs_col .nano>.nano-pane>.nano-slider { | ||
76 | /*scrollbarbutton when hover*/ | ||
77 | background-color: rgb(40, 44, 52) !important; | ||
78 | } | ||
79 | |||
80 | code, | ||
81 | pre { | ||
82 | background-color: #bbb !important; | ||
83 | color: #0e0e0e; | ||
84 | border: none !important; | ||
85 | } | ||
86 | |||
87 | .tg_head_split { | ||
88 | background-color: #151515; | ||
89 | } | ||
90 | |||
91 | .im_submit { | ||
92 | color: rgb(40, 44, 52); | ||
93 | } | ||
94 | |||
95 | .im_message_mymention { | ||
96 | background: #1d1d1d; | ||
97 | } | ||
98 | |||
99 | .im_message_focus .im_message_outer_wrap { | ||
100 | background-color: rgb(40, 44, 52); | ||
101 | } | ||
102 | |||
103 | .im_message_selected .im_message_outer_wrap { | ||
104 | background: rgb(40, 44, 52); | ||
105 | } | ||
106 | |||
107 | a:hover { | ||
108 | background-color: #282828 !important; | ||
109 | } | ||
110 | |||
111 | .im_message_unread_split { | ||
112 | background: rgb(40, 44, 52); | ||
113 | } | ||
114 | |||
115 | @ keyframes im_message_focus_fade { | ||
116 | 0% { | ||
117 | /*soft transaction*/ | ||
118 | |||
119 | background-color: #2d2d2d; | ||
120 | } | ||
121 | } | ||
122 | |||
123 | .btn-primary { | ||
124 | background-color: rgb(40, 44, 52); | ||
125 | } | ||
126 | |||
127 | .im_history_select_active .im_message_outer_wrap:hover { | ||
128 | background: rgb(40, 44, 52); | ||
129 | } | ||
130 | |||
131 | .im_dialog_chat_from_wrap, | ||
132 | .im_dialog_message_service { | ||
133 | color: #6ac; | ||
134 | } | ||
135 | |||
136 | .composer_rich_textarea, | ||
137 | .composer_textarea { | ||
138 | box-shadow: 0px 3px 1px #ddd; | ||
139 | } | ||
140 | |||
141 | .composer_rich_textarea:focus { | ||
142 | box-shadow: 0px 3px 1px #ddd !important; | ||
143 | } | ||
144 | |||
145 | .tg_head_logo_dropdown .dropdown-menu>li>a, | ||
146 | a.tg_radio { | ||
147 | color: #ddd; | ||
148 | } | ||
149 | |||
150 | .btn-primary.disabled, | ||
151 | .btn-primary[disabled] { | ||
152 | background: rgb(40, 44, 52) none repeat scroll 0% 0%; | ||
153 | } | ||
154 | |||
155 | /*emoji*/ | ||
156 | |||
157 | .composer_emoji_tooltip, | ||
158 | .icon-tooltip-tail, | ||
159 | .dropdown-menu { | ||
160 | background-color: rgb(40, 44, 52) !important; | ||
161 | border-color: #5d5d5d; | ||
162 | } | ||
163 | |||
164 | .im_dialog_badge.badge { | ||
165 | background-color: #bfbfbf30 !important; | ||
166 | } | ||
167 | |||
168 | .im_message_selected .im_message_outer_wrap, | ||
169 | .im_history_select_active .im_message_outer_wrap:hover { | ||
170 | background-color: rgb(40, 44, 52) !important; | ||
171 | } | ||
172 | |||
173 | .reply_markup_button { | ||
174 | color: #FFFFFF !important; | ||
175 | background-color: #666666 !important; | ||
176 | } | ||
177 | |||
178 | .reply_markup_button:focus, | ||
179 | .reply_markup_button:hover { | ||
180 | color: #FFFFFF !important; | ||
181 | background-color: rgb(40, 44, 52) !important; | ||
182 | } | ||
183 | |||
184 | .tg_head_logo_dropdown .dropdown-menu>li>a, | ||
185 | .dropdown-menu>li>a, | ||
186 | .dropdown-menu>li>a, | ||
187 | .dropdown-menu>li>a:focus, | ||
188 | .dropdown-menu>li>a:hover { | ||
189 | color: #FFFFFF !important; | ||
190 | } | ||
diff --git a/recipes/telegram/package.json b/recipes/telegram/package.json index beda3c3..e537a9c 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.3", | 4 | "version": "3.2.4", |
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 7d2c8e3..d63282e 100644 --- a/recipes/telegram/webview.js +++ b/recipes/telegram/webview.js | |||
@@ -1,5 +1,3 @@ | |||
1 | // Code copied from: https://gitlab.com/gortega4/ferdi_recipes | ||
2 | |||
3 | const _path = _interopRequireDefault(require('path')); | 1 | const _path = _interopRequireDefault(require('path')); |
4 | 2 | ||
5 | function _interopRequireDefault(obj) { | 3 | function _interopRequireDefault(obj) { |
@@ -7,27 +5,76 @@ function _interopRequireDefault(obj) { | |||
7 | } | 5 | } |
8 | 6 | ||
9 | module.exports = Ferdi => { | 7 | module.exports = Ferdi => { |
10 | const getMessages = () => { | 8 | const telegramVersion = document |
11 | let direct = 0; | 9 | .querySelector('meta[name="application-name"]') |
12 | let indirect = 0; | 10 | ?.getAttribute('content'); |
13 | const elements = document.querySelectorAll('.rp'); | 11 | |
12 | const isWebZ = telegramVersion?.includes('WebZ'); | ||
13 | const isWebK = telegramVersion?.includes('WebK'); | ||
14 | |||
15 | // There are two different Telegram versions for internal competition | ||
16 | // Read more: https://bugs.telegram.org/c/4002/public | ||
17 | const webZCount = () => { | ||
18 | let directCount = 0; | ||
19 | let groupCount = 0; | ||
20 | |||
21 | const directCountSelector = document.querySelectorAll( | ||
22 | '.chat-list .ListItem.private .Badge.unread:not(.muted)', | ||
23 | ); | ||
24 | const groupCountSelector = document.querySelectorAll( | ||
25 | '.chat-list .ListItem.group .Badge.unread:not(.muted)', | ||
26 | ); | ||
27 | |||
28 | for (const badge of directCountSelector) { | ||
29 | directCount += Ferdi.safeParseInt(badge.textContent); | ||
30 | } | ||
31 | |||
32 | for (const badge of groupCountSelector) { | ||
33 | groupCount += Ferdi.safeParseInt(badge.textContent); | ||
34 | } | ||
35 | |||
36 | Ferdi.setBadge(directCount, groupCount); | ||
37 | }; | ||
38 | |||
39 | const webKCount = () => { | ||
40 | let directCount = 0; | ||
41 | let groupCount = 0; | ||
42 | |||
43 | const elements = document.querySelectorAll('.rp:not(.is-muted)'); | ||
44 | |||
14 | for (const element of elements) { | 45 | for (const element of elements) { |
15 | const subtitleBadge = element.querySelector('.dialog-subtitle-badge'); | 46 | const subtitleBadge = element.querySelector('.dialog-subtitle-badge'); |
47 | |||
16 | if (subtitleBadge) { | 48 | if (subtitleBadge) { |
17 | const parsedValue = Ferdi.safeParseInt(subtitleBadge.textContent); | 49 | const parsedValue = Ferdi.safeParseInt(subtitleBadge.textContent); |
50 | |||
18 | if (element.dataset.peerId > 0) { | 51 | if (element.dataset.peerId > 0) { |
19 | direct += parsedValue; | 52 | directCount += parsedValue; |
20 | } else { | 53 | } else { |
21 | indirect += parsedValue; | 54 | groupCount += parsedValue; |
22 | } | 55 | } |
23 | } | 56 | } |
24 | } | 57 | } |
25 | 58 | ||
26 | Ferdi.setBadge(direct, indirect); | 59 | Ferdi.setBadge(directCount, groupCount); |
60 | }; | ||
61 | |||
62 | const getMessages = () => { | ||
63 | if (isWebZ) { | ||
64 | webZCount(); | ||
65 | } else if (isWebK) { | ||
66 | webKCount(); | ||
67 | } | ||
27 | }; | 68 | }; |
28 | 69 | ||
29 | const getActiveDialogTitle = () => { | 70 | const getActiveDialogTitle = () => { |
30 | const element = document.querySelector('.top .peer-title'); | 71 | let element; |
72 | |||
73 | if (isWebZ) { | ||
74 | element = document.querySelector('.chat-list .ListItem .title > h3'); | ||
75 | } else if (isWebK) { | ||
76 | element = document.querySelector('.top .peer-title'); | ||
77 | } | ||
31 | 78 | ||
32 | Ferdi.setDialogTitle(element ? element.textContent : ''); | 79 | Ferdi.setDialogTitle(element ? element.textContent : ''); |
33 | }; | 80 | }; |