diff options
author | Sampath Kumar Krishnan <sampathBlam@users.noreply.github.com> | 2020-04-24 23:26:06 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-24 17:56:06 +0000 |
commit | b7e866909a1c96be5965c57289af551869dce2aa (patch) | |
tree | 491bae1d1fb98c1dee5ba9058974737d8ca3ce25 | |
parent | Update agent agent configuration (diff) | |
download | ferdium-recipes-b7e866909a1c96be5965c57289af551869dce2aa.tar.gz ferdium-recipes-b7e866909a1c96be5965c57289af551869dce2aa.tar.zst ferdium-recipes-b7e866909a1c96be5965c57289af551869dce2aa.zip |
Implement modifyRequestHeaders for Hangouts and document (#137)
Co-Authored-By: Mahadevan Sreenivasan <mahadevan_sv@yahoo.com>
-rw-r--r-- | all.json | 2 | ||||
-rw-r--r-- | archives/hangoutschat.tar.gz | bin | 113884 -> 114002 bytes | |||
-rw-r--r-- | docs/backend_api.md | 28 | ||||
-rw-r--r-- | uncompressed/hangoutschat/index.js | 10 | ||||
-rw-r--r-- | uncompressed/hangoutschat/package.json | 2 |
5 files changed, 40 insertions, 2 deletions
@@ -345,7 +345,7 @@ | |||
345 | "featured": false, | 345 | "featured": false, |
346 | "id": "hangoutschat", | 346 | "id": "hangoutschat", |
347 | "name": "Hangouts Chat", | 347 | "name": "Hangouts Chat", |
348 | "version": "1.2.3", | 348 | "version": "1.3.0", |
349 | "icons": { | 349 | "icons": { |
350 | "png": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/hangoutschat/icon.png", | 350 | "png": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/hangoutschat/icon.png", |
351 | "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/hangoutschat/icon.svg" | 351 | "svg": "https://cdn.jsdelivr.net/gh/getferdi/recipes/uncompressed/hangoutschat/icon.svg" |
diff --git a/archives/hangoutschat.tar.gz b/archives/hangoutschat.tar.gz index b1fdc9c..39d9ae0 100644 --- a/archives/hangoutschat.tar.gz +++ b/archives/hangoutschat.tar.gz | |||
Binary files differ | |||
diff --git a/docs/backend_api.md b/docs/backend_api.md index 512912b..dc3bfaa 100644 --- a/docs/backend_api.md +++ b/docs/backend_api.md | |||
@@ -5,6 +5,7 @@ Provides a set of helper functions to integrate the recipe into [Ferdi](https:// | |||
5 | ## Ferdi Backend Class Methods | 5 | ## Ferdi Backend Class Methods |
6 | * [validateUrl](#user-content-validateurl) | 6 | * [validateUrl](#user-content-validateurl) |
7 | * [overrideUserAgent](#user-content-overrideuseragent) | 7 | * [overrideUserAgent](#user-content-overrideuseragent) |
8 | * [modifyRequestHeaders](#user-content-modifyrequestheaders) | ||
8 | 9 | ||
9 | ## Events | 10 | ## Events |
10 | * [webview events](#user-content-events) | 11 | * [webview events](#user-content-events) |
@@ -72,6 +73,32 @@ module.exports = Ferdi => class Example extends Ferdi { | |||
72 | }; | 73 | }; |
73 | ``` | 74 | ``` |
74 | 75 | ||
76 | ### modifyRequestHeaders() | ||
77 | Modify headers of HTTP requests sent from a recipe's webview | ||
78 | Any standard HTTP header can be added to the requests. | ||
79 | |||
80 | #### Returns | ||
81 | `Array` containing objects, each of which should have two properties. | ||
82 | - `headers` - Object containing the header params and their values in key-value format | ||
83 | - `requestFilters` - Array of URL patterns used to filter requests for which the headers need to be added. | ||
84 | Valid URL patterns can be referred from [here](https://www.electronjs.org/docs/api/web-request#webrequestonbeforerequestfilter-listener) | ||
85 | |||
86 | #### Usage | ||
87 | |||
88 | ```js | ||
89 | // Hangouts Chat integration | ||
90 | module.exports = Ferdi => class HangoutsChat extends Ferdi { | ||
91 | modifyRequestHeaders() { | ||
92 | return [{ | ||
93 | // Adding an origin header for all http requests from this recipe | ||
94 | headers: { 'origin': 'https://chat.google.com' }, | ||
95 | requestFilters: { | ||
96 | urls: ['*://*/*'] | ||
97 | } | ||
98 | }] | ||
99 | } | ||
100 | }; | ||
101 | ``` | ||
75 | 102 | ||
76 | ### Events | 103 | ### Events |
77 | Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions. | 104 | Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions. |
@@ -95,3 +122,4 @@ module.exports = Ferdi => class Tweetdeck extends Ferdi { | |||
95 | } | 122 | } |
96 | }; | 123 | }; |
97 | ``` | 124 | ``` |
125 | |||
diff --git a/uncompressed/hangoutschat/index.js b/uncompressed/hangoutschat/index.js index 95e7fa5..819e06b 100644 --- a/uncompressed/hangoutschat/index.js +++ b/uncompressed/hangoutschat/index.js | |||
@@ -3,6 +3,16 @@ var os = require('os') | |||
3 | // just pass through Franz | 3 | // just pass through Franz |
4 | module.exports = Franz => | 4 | module.exports = Franz => |
5 | class HangoutsChat extends 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 | |||
6 | overrideUserAgent() { | 16 | overrideUserAgent() { |
7 | if (os.platform() == 'linux') | 17 | if (os.platform() == 'linux') |
8 | return "Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0" | 18 | return "Mozilla/5.0 (X11; Linux x86_64; rv:72.0) Gecko/20100101 Firefox/72.0" |
diff --git a/uncompressed/hangoutschat/package.json b/uncompressed/hangoutschat/package.json index 40b0357..bcc58f9 100644 --- a/uncompressed/hangoutschat/package.json +++ b/uncompressed/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.2.3", | 4 | "version": "1.3.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)", |