aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/hangoutschat
diff options
context:
space:
mode:
authorLibravatar Mahadevan Sreenivasan <mahadevan_sv@yahoo.com>2020-10-02 19:19:45 +0530
committerLibravatar GitHub <noreply@github.com>2020-10-02 14:49:45 +0100
commitfe97c525fc8411f4b0a9658f8732bfa94a667c2d (patch)
treee844e547bf90488821c2b4bafb1efc732a075019 /recipes/hangoutschat
parentMerge pull request #301 from stephenpapierski/master (diff)
downloadferdium-recipes-fe97c525fc8411f4b0a9658f8732bfa94a667c2d.tar.gz
ferdium-recipes-fe97c525fc8411f4b0a9658f8732bfa94a667c2d.tar.zst
ferdium-recipes-fe97c525fc8411f4b0a9658f8732bfa94a667c2d.zip
Update Hangouts Chat to display direct and indirect notifications (#306)
Diffstat (limited to 'recipes/hangoutschat')
-rw-r--r--recipes/hangoutschat/package.json2
-rw-r--r--recipes/hangoutschat/webview.js24
2 files changed, 16 insertions, 10 deletions
diff --git a/recipes/hangoutschat/package.json b/recipes/hangoutschat/package.json
index bcc58f9..5ffc252 100644
--- a/recipes/hangoutschat/package.json
+++ b/recipes/hangoutschat/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "hangoutschat", 2 "id": "hangoutschat",
3 "name": "Hangouts Chat", 3 "name": "Hangouts Chat",
4 "version": "1.3.0", 4 "version": "1.4.0",
5 "description": "Hangouts Chat", 5 "description": "Hangouts Chat",
6 "main": "index.js", 6 "main": "index.js",
7 "author": "Stefan Malzner <stefan@adlk.io> and Iván López (ilopmar)", 7 "author": "Stefan Malzner <stefan@adlk.io> and Iván López (ilopmar)",
diff --git a/recipes/hangoutschat/webview.js b/recipes/hangoutschat/webview.js
index 9597f58..8d51278 100644
--- a/recipes/hangoutschat/webview.js
+++ b/recipes/hangoutschat/webview.js
@@ -1,15 +1,21 @@
1module.exports = (Franz) => { 1module.exports = (Franz) => {
2
3 // class corresponding to the mute icon 2 // class corresponding to the mute icon
4 const muteSelector = '.DQy0Rb'; 3 const muteSelector = ".DQy0Rb";
5 4
6 // class corresponding to the red badge that is visible for direct messages 5 // class corresponding to the red badge that is visible for direct messages
7 const directMessageSelector = '.SaMfhe.m9MHid'; 6 const directMessageSelector = ".SaMfhe.m9MHid";
8 7
9 // class corresponding to the bold text that is visible for all messages 8 // class corresponding to the bold text that is visible for all messages
10 const allMessageSelector = '.IL9EXe.PL5Wwe.dHI9xe.H7du2'; 9 const allMessageSelector = ".IL9EXe.PL5Wwe.dHI9xe.H7du2";
11 10
12 const isMuted = node => !!node.closest('[role="listitem"]').querySelector(muteSelector); 11 const isMuted = (node) => {
12 closestItem = node.closest('[role="listitem"]')
13 if (closestItem) {
14 return !!closestItem.querySelector(muteSelector);
15 } else {
16 return true;
17 }
18 }
13 19
14 const getMessages = function getMessages() { 20 const getMessages = function getMessages() {
15 let allMessageCount = 0; 21 let allMessageCount = 0;
@@ -19,7 +25,7 @@ module.exports = (Franz) => {
19 document.querySelectorAll(directMessageSelector).forEach((node) => { 25 document.querySelectorAll(directMessageSelector).forEach((node) => {
20 // Hangouts Chat overrides the muted indicator when there is a direct mention 26 // Hangouts Chat overrides the muted indicator when there is a direct mention
21 // Check for the width of the badge element 27 // Check for the width of the badge element
22 if (!isMuted(node) && node.clientWidth != 0 ) { 28 if (!isMuted(node) && node.clientWidth != 0) {
23 directCount += 1; 29 directCount += 1;
24 } 30 }
25 }); 31 });
@@ -36,10 +42,10 @@ module.exports = (Franz) => {
36 Franz.setBadge(directCount, indirectCount); 42 Franz.setBadge(directCount, indirectCount);
37 }; 43 };
38 44
39 document.addEventListener('click', (e) => { 45 document.addEventListener("click", (e) => {
40 const { tagName, target, href } = e.target; 46 const { tagName, target, href } = e.target;
41 47
42 if (tagName === 'A' && target === '_blank') { 48 if (tagName === "A" && target === "_blank") {
43 e.preventDefault(); 49 e.preventDefault();
44 e.stopImmediatePropagation(); 50 e.stopImmediatePropagation();
45 window.open(href); 51 window.open(href);