aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorLibravatar Vijay A <avijayr@protonmail.com>2021-05-16 12:47:35 +0530
committerLibravatar Vijay Raghavan Aravamudhan <vraravam@users.noreply.github.com>2021-05-16 12:56:23 +0530
commit2dd01c7e03700a217d143ab25ee187acb70b70bf (patch)
treef6b61f95a1774a48a65123f8acb6c2154b0da796 /docs
parentFixing login redirect issue in PushBullet (fixes Ferdi#1331) (diff)
downloadferdium-recipes-2dd01c7e03700a217d143ab25ee187acb70b70bf.tar.gz
ferdium-recipes-2dd01c7e03700a217d143ab25ee187acb70b70bf.tar.zst
ferdium-recipes-2dd01c7e03700a217d143ab25ee187acb70b70bf.zip
Fixing incorrect example in TweetDeck.
Diffstat (limited to 'docs')
-rw-r--r--docs/backend_api.md29
1 files changed, 19 insertions, 10 deletions
diff --git a/docs/backend_api.md b/docs/backend_api.md
index dc3bfaa..dd7d760 100644
--- a/docs/backend_api.md
+++ b/docs/backend_api.md
@@ -3,20 +3,25 @@
3Provides a set of helper functions to integrate the recipe into [Ferdi](https://getferdi.com). 3Provides a set of helper functions to integrate the recipe into [Ferdi](https://getferdi.com).
4 4
5## Ferdi Backend Class Methods 5## Ferdi Backend Class Methods
6
6* [validateUrl](#user-content-validateurl) 7* [validateUrl](#user-content-validateurl)
7* [overrideUserAgent](#user-content-overrideuseragent) 8* [overrideUserAgent](#user-content-overrideuseragent)
8* [modifyRequestHeaders](#user-content-modifyrequestheaders) 9* [modifyRequestHeaders](#user-content-modifyrequestheaders)
9 10
10## Events 11## Events
12
11* [webview events](#user-content-events) 13* [webview events](#user-content-events)
12 14
13### validateUrl(URL) 15### validateUrl(URL)
14Validate if the given URL is a valid service instance. 16
17Validate if the given URL is a valid service instance.
15 18
16#### Arguments 19#### Arguments
20
171. `string` URL 211. `string` URL
18 22
19#### Returns 23#### Returns
24
20[`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) 25[`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise)
21 26
22#### Usage 27#### Usage
@@ -45,9 +50,11 @@ module.exports = Ferdi => class RocketChat extends Ferdi {
45``` 50```
46 51
47### overrideUserAgent() 52### overrideUserAgent()
48Override the user agent used inside the service webview. 53
54Override the user agent used inside the service webview.
49 55
50#### Returns 56#### Returns
57
51`String` 58`String`
52 59
53#### Usage 60#### Usage
@@ -74,13 +81,16 @@ module.exports = Ferdi => class Example extends Ferdi {
74``` 81```
75 82
76### modifyRequestHeaders() 83### modifyRequestHeaders()
84
77Modify headers of HTTP requests sent from a recipe's webview 85Modify headers of HTTP requests sent from a recipe's webview
78Any standard HTTP header can be added to the requests. 86Any standard HTTP header can be added to the requests.
79 87
80#### Returns 88#### Returns
89
81`Array` containing objects, each of which should have two properties. 90`Array` containing objects, each of which should have two properties.
82- `headers` - Object containing the header params and their values in key-value format 91
83- `requestFilters` - Array of URL patterns used to filter requests for which the headers need to be added. 92* `headers` - Object containing the header params and their values in key-value format
93* `requestFilters` - Array of URL patterns used to filter requests for which the headers need to be added.
84Valid URL patterns can be referred from [here](https://www.electronjs.org/docs/api/web-request#webrequestonbeforerequestfilter-listener) 94Valid URL patterns can be referred from [here](https://www.electronjs.org/docs/api/web-request#webrequestonbeforerequestfilter-listener)
85 95
86#### Usage 96#### Usage
@@ -101,11 +111,13 @@ module.exports = Ferdi => class HangoutsChat extends Ferdi {
101``` 111```
102 112
103### Events 113### Events
114
104Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions. 115Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions.
105 116
106This is necessary for services like TweetDeck where custom URL forwarding is needed during login. 117This is necessary for services like TweetDeck where custom URL forwarding is needed during login.
107 118
108#### Usage 119#### Usage
120
109```js 121```js
110module.exports = Ferdi => class Tweetdeck extends Ferdi { 122module.exports = Ferdi => class Tweetdeck extends Ferdi {
111 events = { 123 events = {
@@ -114,12 +126,9 @@ module.exports = Ferdi => class Tweetdeck extends Ferdi {
114 126
115 _redirectFix(event) { 127 _redirectFix(event) {
116 if (event.newURL !== undefined && event.oldURL !== undefined && event.isMainFrame) { 128 if (event.newURL !== undefined && event.oldURL !== undefined && event.isMainFrame) {
117 if (event.isMainFrame) { 129 setTimeout(() => this.send('redirect-url', event.newURL), 100);
118 setTimeout(() => this.send('redirect-url', event.newURL), 100); 130 event.preventDefault();
119 event.preventDefault();
120 }
121 } 131 }
122 } 132 }
123}; 133};
124``` 134```
125