From 2dd01c7e03700a217d143ab25ee187acb70b70bf Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sun, 16 May 2021 12:47:35 +0530 Subject: Fixing incorrect example in TweetDeck. --- docs/backend_api.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'docs/backend_api.md') 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 @@ Provides a set of helper functions to integrate the recipe into [Ferdi](https://getferdi.com). ## Ferdi Backend Class Methods + * [validateUrl](#user-content-validateurl) * [overrideUserAgent](#user-content-overrideuseragent) * [modifyRequestHeaders](#user-content-modifyrequestheaders) ## Events + * [webview events](#user-content-events) ### validateUrl(URL) -Validate if the given URL is a valid service instance. + +Validate if the given URL is a valid service instance. #### Arguments + 1. `string` URL #### Returns + [`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) #### Usage @@ -45,9 +50,11 @@ module.exports = Ferdi => class RocketChat extends Ferdi { ``` ### overrideUserAgent() -Override the user agent used inside the service webview. + +Override the user agent used inside the service webview. #### Returns + `String` #### Usage @@ -74,13 +81,16 @@ module.exports = Ferdi => class Example extends Ferdi { ``` ### modifyRequestHeaders() + Modify headers of HTTP requests sent from a recipe's webview -Any standard HTTP header can be added to the requests. +Any standard HTTP header can be added to the requests. #### Returns + `Array` containing objects, each of which should have two properties. -- `headers` - Object containing the header params and their values in key-value format -- `requestFilters` - Array of URL patterns used to filter requests for which the headers need to be added. + +* `headers` - Object containing the header params and their values in key-value format +* `requestFilters` - Array of URL patterns used to filter requests for which the headers need to be added. Valid URL patterns can be referred from [here](https://www.electronjs.org/docs/api/web-request#webrequestonbeforerequestfilter-listener) #### Usage @@ -101,11 +111,13 @@ module.exports = Ferdi => class HangoutsChat extends Ferdi { ``` ### Events + Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions. This is necessary for services like TweetDeck where custom URL forwarding is needed during login. #### Usage + ```js module.exports = Ferdi => class Tweetdeck extends Ferdi { events = { @@ -114,12 +126,9 @@ module.exports = Ferdi => class Tweetdeck extends Ferdi { _redirectFix(event) { if (event.newURL !== undefined && event.oldURL !== undefined && event.isMainFrame) { - if (event.isMainFrame) { - setTimeout(() => this.send('redirect-url', event.newURL), 100); - event.preventDefault(); - } + setTimeout(() => this.send('redirect-url', event.newURL), 100); + event.preventDefault(); } } }; ``` - -- cgit v1.2.3-54-g00ecf