aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/hangoutschat
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/hangoutschat')
-rw-r--r--recipes/hangoutschat/README.md14
-rw-r--r--recipes/hangoutschat/icon.pngbin0 -> 112748 bytes
-rw-r--r--recipes/hangoutschat/icon.svg9
-rw-r--r--recipes/hangoutschat/index.js22
-rw-r--r--recipes/hangoutschat/package.json15
-rw-r--r--recipes/hangoutschat/webview.js51
6 files changed, 111 insertions, 0 deletions
diff --git a/recipes/hangoutschat/README.md b/recipes/hangoutschat/README.md
new file mode 100644
index 0000000..3ac9e49
--- /dev/null
+++ b/recipes/hangoutschat/README.md
@@ -0,0 +1,14 @@
1# Hangouts Chat for Franz
2
3This is a clone of the [official Franz recipe for Hangouts Chat](https://github.com/meetfranz/recipe-hangoutschat) to
4merge the pending PRs, specially the one that fixes the notifications badge.
5
6## Installation
7
8You need to apply the plugin manually.
9
101. Create the directory `~/.config/Franz/recipes/dev/recipe-hangoutschat`
112. Copy the files from this repository into the new folder
123. Reload Franz
134. Add "Hangouts Chat (Non official)" in Add Service > Custom Service > Hangouts Chat (Non official)
145. Close Franz, start it again and add your account again.
diff --git a/recipes/hangoutschat/icon.png b/recipes/hangoutschat/icon.png
new file mode 100644
index 0000000..2f7120e
--- /dev/null
+++ b/recipes/hangoutschat/icon.png
Binary files differ
diff --git a/recipes/hangoutschat/icon.svg b/recipes/hangoutschat/icon.svg
new file mode 100644
index 0000000..9238971
--- /dev/null
+++ b/recipes/hangoutschat/icon.svg
@@ -0,0 +1,9 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1024" height="1024" viewBox="0 0 1024 1024" version="1.1">
3<g id="surface1">
4<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,53.72549%,48.235294%);fill-opacity:1;" d="M 512 0 C 276.351562 0 85.332031 191.039062 85.332031 426.730469 C 85.332031 662.421875 276.351562 853.460938 512 853.460938 L 512 1024 C 532.308594 1024 938.667969 812.800781 938.667969 426.730469 C 938.667969 191.039062 747.648438 0 512 0 Z M 512 0 "/>
5<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,47.45098%,41.960784%);fill-opacity:1;" d="M 931.625 514.347656 C 901.121094 698.878906 779.519531 836.265625 674.988281 921.601562 L 346.027344 592.640625 C 254.292969 500.90625 254.292969 352.425781 346.027344 260.691406 C 437.761719 168.960938 586.238281 168.960938 677.972656 260.691406 Z M 931.625 514.347656 "/>
6<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 512 554.667969 C 441.40625 554.667969 384 497.257812 384 426.667969 C 384 356.074219 441.40625 298.667969 512 298.667969 C 569.769531 298.667969 640 356.074219 640 426.667969 C 640 497.257812 582.59375 554.667969 512 554.667969 Z M 512 352 C 470.335938 352 437.332031 384 437.332031 426.667969 C 437.332031 469.332031 468.886719 501.332031 512 501.332031 C 559.0625 501.332031 586.667969 473.726562 586.667969 426.667969 C 586.667969 379.605469 559.0625 352 512 352 Z M 512 352 "/>
7<path style=" stroke:none;fill-rule:nonzero;fill:rgb(100%,100%,100%);fill-opacity:1;" d="M 512 661.332031 C 384.789062 661.332031 277.332031 553.855469 277.332031 426.667969 C 277.332031 299.476562 384.789062 192 512 192 C 639.210938 192 746.667969 299.476562 746.667969 426.667969 C 746.667969 506.816406 717.953125 554.667969 669.867188 554.667969 C 642.773438 554.667969 597.332031 538.046875 597.332031 426.667969 L 597.332031 320 L 640 320 L 640 426.667969 C 640 480.105469 651.15625 512 669.867188 512 C 693.441406 512 704 469.140625 704 426.667969 C 704 322.601562 616.085938 234.667969 512 234.667969 C 407.914062 234.667969 320 322.601562 320 426.667969 C 320 530.730469 407.914062 618.667969 512 618.667969 C 564.542969 618.667969 599.105469 601.707031 599.445312 601.515625 L 618.539062 639.679688 C 616.746094 640.574219 574.507812 661.332031 512 661.332031 Z M 512 661.332031 "/>
8</g>
9</svg>
diff --git a/recipes/hangoutschat/index.js b/recipes/hangoutschat/index.js
new file mode 100644
index 0000000..819e06b
--- /dev/null
+++ b/recipes/hangoutschat/index.js
@@ -0,0 +1,22 @@
1var os = require('os')
2
3// just pass through Franz
4module.exports = Franz =>
5 class HangoutsChat extends Franz {
6 // Method to add headers to requests from Hangouts Chat's webview
7 modifyRequestHeaders() {
8 return [{
9 headers: { 'origin': 'https://chat.google.com' },
10 requestFilters: {
11 urls: ['*://*/*']
12 }
13 }]
14 }
15
16 overrideUserAgent() {
17 if (os.platform() == 'linux')
18 return "Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0"
19 else
20 return "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:72.0) Gecko/20100101 Firefox/72.0";
21 }
22 };
diff --git a/recipes/hangoutschat/package.json b/recipes/hangoutschat/package.json
new file mode 100644
index 0000000..bcc58f9
--- /dev/null
+++ b/recipes/hangoutschat/package.json
@@ -0,0 +1,15 @@
1{
2 "id": "hangoutschat",
3 "name": "Hangouts Chat",
4 "version": "1.3.0",
5 "description": "Hangouts Chat",
6 "main": "index.js",
7 "author": "Stefan Malzner <stefan@adlk.io> and Iván López (ilopmar)",
8 "license": "MIT",
9 "config": {
10 "serviceURL": "https://chat.google.com",
11 "hasNotificationSound": true,
12 "hasIndirectMessages": true,
13 "dissablewebsecurity": true
14 }
15}
diff --git a/recipes/hangoutschat/webview.js b/recipes/hangoutschat/webview.js
new file mode 100644
index 0000000..9597f58
--- /dev/null
+++ b/recipes/hangoutschat/webview.js
@@ -0,0 +1,51 @@
1module.exports = (Franz) => {
2
3 // class corresponding to the mute icon
4 const muteSelector = '.DQy0Rb';
5
6 // class corresponding to the red badge that is visible for direct messages
7 const directMessageSelector = '.SaMfhe.m9MHid';
8
9 // class corresponding to the bold text that is visible for all messages
10 const allMessageSelector = '.IL9EXe.PL5Wwe.dHI9xe.H7du2';
11
12 const isMuted = node => !!node.closest('[role="listitem"]').querySelector(muteSelector);
13
14 const getMessages = function getMessages() {
15 let allMessageCount = 0;
16 let directCount = 0;
17
18 // get unread direct messages
19 document.querySelectorAll(directMessageSelector).forEach((node) => {
20 // Hangouts Chat overrides the muted indicator when there is a direct mention
21 // Check for the width of the badge element
22 if (!isMuted(node) && node.clientWidth != 0 ) {
23 directCount += 1;
24 }
25 });
26
27 let indirectCount = 0;
28 document.querySelectorAll(allMessageSelector).forEach((node) => {
29 if (!isMuted(node)) {
30 allMessageCount += 1;
31 }
32 });
33 indirectCount = allMessageCount - directCount;
34
35 // set Franz badge
36 Franz.setBadge(directCount, indirectCount);
37 };
38
39 document.addEventListener('click', (e) => {
40 const { tagName, target, href } = e.target;
41
42 if (tagName === 'A' && target === '_blank') {
43 e.preventDefault();
44 e.stopImmediatePropagation();
45 window.open(href);
46 }
47 });
48
49 // check for new messages every second and update Franz badge
50 Franz.loop(getMessages);
51};