diff options
Diffstat (limited to 'docs/backend_api.md')
-rw-r--r-- | docs/backend_api.md | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/docs/backend_api.md b/docs/backend_api.md index dfc9f22..512912b 100644 --- a/docs/backend_api.md +++ b/docs/backend_api.md | |||
@@ -44,28 +44,35 @@ module.exports = Ferdi => class RocketChat extends Ferdi { | |||
44 | ``` | 44 | ``` |
45 | 45 | ||
46 | ### overrideUserAgent() | 46 | ### overrideUserAgent() |
47 | Validate if the given URL is a valid service instance. | 47 | Override the user agent used inside the service webview. |
48 | 48 | ||
49 | #### Returns | 49 | #### Returns |
50 | `Boolean` | 50 | `String` |
51 | 51 | ||
52 | #### Usage | 52 | #### Usage |
53 | 53 | ||
54 | ```js | 54 | ```js |
55 | // Discord integration | ||
56 | module.exports = Ferdi => class Discord extends Ferdi { | 55 | module.exports = Ferdi => class Discord extends Ferdi { |
57 | overrideUserAgent() { | 56 | overrideUserAgent() { |
58 | const useragent = window.navigator.userAgent; | 57 | // Remove Ferdi's signature from the user agent |
59 | 58 | return window.navigator.userAgent.replace( | |
60 | // Quick and dirty hackfix | 59 | /(Ferdi|Electron)\/\S+ \([^)]+\)/g, |
61 | const parts = useragent.split('(KHTML, like Gecko)'); | 60 | "" |
62 | 61 | ); | |
63 | return parts.join('(KHTML, like Gecko) discord/0.0.248').replace('Electron', 'Discord').replace('Ferdi', 'Discord'); | ||
64 | } | 62 | } |
65 | }; | 63 | }; |
64 | ``` | ||
66 | 65 | ||
66 | ```js | ||
67 | module.exports = Ferdi => class Example extends Ferdi { | ||
68 | overrideUserAgent() { | ||
69 | // Use a completely different user agent | ||
70 | return "Mozilla/2.02Gold (Win95; I)"; | ||
71 | } | ||
72 | }; | ||
67 | ``` | 73 | ``` |
68 | 74 | ||
75 | |||
69 | ### Events | 76 | ### Events |
70 | Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions. | 77 | Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions. |
71 | 78 | ||