aboutsummaryrefslogtreecommitdiffstats
path: root/recipes
diff options
context:
space:
mode:
authorLibravatar Iaroslav <yavoloh@mail.ru>2021-10-26 07:59:12 +0500
committerLibravatar GitHub <noreply@github.com>2021-10-26 08:29:12 +0530
commit87731bd4a54dc3c40e0188d790d0f430cacf1ef6 (patch)
tree7b88a8d187ae1ff27651792aea447c3b523d518f /recipes
parentchore: upgrade 'pnpm' to '6.19.0' (diff)
downloadferdium-recipes-87731bd4a54dc3c40e0188d790d0f430cacf1ef6.tar.gz
ferdium-recipes-87731bd4a54dc3c40e0188d790d0f430cacf1ef6.tar.zst
ferdium-recipes-87731bd4a54dc3c40e0188d790d0f430cacf1ef6.zip
Add dialog title for VK, FB and Slack (#753)
Diffstat (limited to 'recipes')
-rwxr-xr-xrecipes/facebook/package.json2
-rwxr-xr-xrecipes/facebook/webview.js20
-rw-r--r--recipes/slack/package.json2
-rw-r--r--recipes/slack/webview.js40
-rw-r--r--recipes/vk/package.json2
-rw-r--r--recipes/vk/webview.js18
6 files changed, 72 insertions, 12 deletions
diff --git a/recipes/facebook/package.json b/recipes/facebook/package.json
index 2f5a54a..53bc486 100755
--- a/recipes/facebook/package.json
+++ b/recipes/facebook/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "facebook", 2 "id": "facebook",
3 "name": "Facebook", 3 "name": "Facebook",
4 "version": "1.1.1", 4 "version": "1.1.2",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://www.facebook.com/login" 7 "serviceURL": "https://www.facebook.com/login"
diff --git a/recipes/facebook/webview.js b/recipes/facebook/webview.js
index b38a2fb..3100935 100755
--- a/recipes/facebook/webview.js
+++ b/recipes/facebook/webview.js
@@ -20,5 +20,23 @@ module.exports = Ferdi => {
20 Ferdi.setBadge(count); 20 Ferdi.setBadge(count);
21 }; 21 };
22 22
23 Ferdi.loop(getNotifications); 23 const getActiveDialogTitle = () => {
24 const element = [
25 document.querySelector(
26 '.cbu4d94t:not(.kr9hpln1) .l9j0dhe7 .pfnyh3mw .g5gj957u .ni8dbmo4.stjgntxs.g0qnabr5.ltmttdrg.ekzkrbhg.mdldhsdk.oo9gr5id',
27 ),
28 document.querySelector(
29 '.j83agx80.cbu4d94t.d6urw2fd.dp1hu0rb.l9j0dhe7.du4w35lb:not(.kr9hpln1) .rq0escxv[role="main"] .t6p9ggj4.tkr6xdv7 .d2edcug0.j83agx80.bp9cbjyn.aahdfvyu.bi6gxh9e .a8c37x1j.ni8dbmo4.stjgntxs.l9j0dhe7.ltmttdrg.g0qnabr5.ojkyduve a.lzcic4wl.gmql0nx0.gpro0wi8.lrazzd5p',
30 ),
31 ].find(Boolean);
32
33 Ferdi.setDialogTitle(element ? element.textContent : null);
34 };
35
36 const loopFunc = () => {
37 getNotifications();
38 getActiveDialogTitle();
39 };
40
41 Ferdi.loop(loopFunc);
24}; 42};
diff --git a/recipes/slack/package.json b/recipes/slack/package.json
index db05b26..3a8f248 100644
--- a/recipes/slack/package.json
+++ b/recipes/slack/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "slack", 2 "id": "slack",
3 "name": "Slack", 3 "name": "Slack",
4 "version": "1.3.2", 4 "version": "1.3.3",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://{teamId}.slack.com", 7 "serviceURL": "https://{teamId}.slack.com",
diff --git a/recipes/slack/webview.js b/recipes/slack/webview.js
index f436ba9..924784d 100644
--- a/recipes/slack/webview.js
+++ b/recipes/slack/webview.js
@@ -1,29 +1,55 @@
1const _path = _interopRequireDefault(require('path')); 1const _path = _interopRequireDefault(require('path'));
2 2
3function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } 3function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj };
5}
4 6
5const SELECTOR_CHANNELS_UNREAD = '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)'; 7const SELECTOR_CHANNELS_UNREAD =
8 '.p-channel_sidebar__channel--unread:not(.p-channel_sidebar__channel--muted)';
6 9
7module.exports = Ferdi => { 10module.exports = Ferdi => {
8 const getMessages = () => { 11 const getMessages = () => {
9 const directMessages = document.querySelectorAll(`${SELECTOR_CHANNELS_UNREAD} .p-channel_sidebar__badge, .p-channel_sidebar__link--unread:not([data-sidebar-link-id="Punreads"]):not([data-sidebar-link-id="Pdrafts"]):not([data-sidebar-link-id="Pdms"])`).length; 12 const directMessages = document.querySelectorAll(
10 const allMessages = document.querySelectorAll(SELECTOR_CHANNELS_UNREAD).length - directMessages; 13 `${SELECTOR_CHANNELS_UNREAD} .p-channel_sidebar__badge, .p-channel_sidebar__link--unread:not([data-sidebar-link-id="Punreads"]):not([data-sidebar-link-id="Pdrafts"]):not([data-sidebar-link-id="Pdms"])`,
14 ).length;
15 const allMessages =
16 document.querySelectorAll(SELECTOR_CHANNELS_UNREAD).length -
17 directMessages;
11 Ferdi.setBadge(directMessages, allMessages); 18 Ferdi.setBadge(directMessages, allMessages);
12 }; 19 };
13 20
14 Ferdi.loop(getMessages); 21 const getActiveDialogTitle = () => {
22 const element = document.querySelector(
23 '.p-channel_sidebar__channel--selected .p-channel_sidebar__name',
24 );
25
26 Ferdi.setDialogTitle(
27 element && element.firstChild ? element.firstChild.textContent : null,
28 );
29 };
30
31 const loopFunc = () => {
32 getMessages();
33 getActiveDialogTitle();
34 };
35
36 Ferdi.loop(loopFunc);
15 37
16 const getTeamIcon = function getTeamIcon(count = 0) { 38 const getTeamIcon = function getTeamIcon(count = 0) {
17 let countTeamIconCheck = count; 39 let countTeamIconCheck = count;
18 let bgUrl = null; 40 let bgUrl = null;
19 const teamMenu = document.querySelector('#team-menu-trigger, .p-ia__sidebar_header__team_name'); 41 const teamMenu = document.querySelector(
42 '#team-menu-trigger, .p-ia__sidebar_header__team_name',
43 );
20 44
21 if (teamMenu) { 45 if (teamMenu) {
22 teamMenu.click(); 46 teamMenu.click();
23 const icon = document.querySelector('.c-team_icon'); 47 const icon = document.querySelector('.c-team_icon');
24 48
25 if (icon) { 49 if (icon) {
26 bgUrl = window.getComputedStyle(icon, null).getPropertyValue('background-image'); 50 bgUrl = window
51 .getComputedStyle(icon, null)
52 .getPropertyValue('background-image');
27 bgUrl = /^url\((["']?)(.*)\1\)$/.exec(bgUrl); 53 bgUrl = /^url\((["']?)(.*)\1\)$/.exec(bgUrl);
28 bgUrl = bgUrl ? bgUrl[2] : ''; 54 bgUrl = bgUrl ? bgUrl[2] : '';
29 } 55 }
diff --git a/recipes/vk/package.json b/recipes/vk/package.json
index e4b7dfa..e61c166 100644
--- a/recipes/vk/package.json
+++ b/recipes/vk/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "vk", 2 "id": "vk",
3 "name": "VK", 3 "name": "VK",
4 "version": "1.1.2", 4 "version": "1.1.3",
5 "license": "MIT", 5 "license": "MIT",
6 "repository": "https://github.com/meetfranz/recipe-vk", 6 "repository": "https://github.com/meetfranz/recipe-vk",
7 "config": { 7 "config": {
diff --git a/recipes/vk/webview.js b/recipes/vk/webview.js
index decec13..6756363 100644
--- a/recipes/vk/webview.js
+++ b/recipes/vk/webview.js
@@ -9,5 +9,21 @@ module.exports = Ferdi => {
9 Ferdi.setBadge(directs); 9 Ferdi.setBadge(directs);
10 }; 10 };
11 11
12 Ferdi.loop(getMessages); 12 const getActiveDialogTitle = () => {
13 const element = [
14 document.querySelector(
15 '.FCWindow--active .FCWindow__title .ConvoTitle__title',
16 ),
17 document.querySelector('.im-page_history-show ._im_page_peer_name'),
18 ].find(Boolean);
19
20 Ferdi.setDialogTitle(element ? element.textContent : null);
21 };
22
23 const loopFunc = () => {
24 getMessages();
25 getActiveDialogTitle();
26 };
27
28 Ferdi.loop(loopFunc);
13}; 29};