aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorLibravatar vantezzen <hello@vantezzen.io>2020-04-24 16:17:49 +0200
committerLibravatar vantezzen <hello@vantezzen.io>2020-04-24 16:17:49 +0200
commitfcc8765fd809ebbd114881083ac5f2ad4a9ba068 (patch)
treeafd1b6d97257a951c40b1cf12979d74bffa157a9 /docs
parentMerge pull request #136 from mahadevans87/patch-1 (diff)
downloadferdium-recipes-fcc8765fd809ebbd114881083ac5f2ad4a9ba068.tar.gz
ferdium-recipes-fcc8765fd809ebbd114881083ac5f2ad4a9ba068.tar.zst
ferdium-recipes-fcc8765fd809ebbd114881083ac5f2ad4a9ba068.zip
Update agent agent configuration
Diffstat (limited to 'docs')
-rw-r--r--docs/backend_api.md25
-rw-r--r--docs/integration.md29
2 files changed, 38 insertions, 16 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()
47Validate if the given URL is a valid service instance. 47Override 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
56module.exports = Ferdi => class Discord extends Ferdi { 55module.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
67module.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
70Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions. 77Ferdi recipes can hook into the [electron webview events](https://electron.atom.io/docs/api/webview-tag/#dom-events) to trigger custom functions.
71 78
diff --git a/docs/integration.md b/docs/integration.md
index ef9e2a5..21d1399 100644
--- a/docs/integration.md
+++ b/docs/integration.md
@@ -100,17 +100,32 @@ module.exports = Ferdi => class RocketChat extends Ferdi {
100`validateServer` needs to return a [`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise), otherwise validation will fail. 100`validateServer` needs to return a [`Promise`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise), otherwise validation will fail.
101 101
102 102
103If you need to override the default user-agent in your service, you can do so like the following snippet of code
104 103
104By default, Ferdi's user agent looks like this:
105``` 105```
106 overrideUserAgent() { 106Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.141 Safari/537.36 Ferdi/5.4.4-beta.3 (Electron 8.1.1)
107 return window.navigator.userAgent.replace(
108 /(Ferdi|Electron)\/\S+ \([^)]+\)/g,
109 ""
110 );
111 }
112``` 107```
113 108
109Some services may not be compatible with Ferdi adding it's signature to the user agent.
110
111If you encounter such a service, you remove this signature with the following snippet of code
112
113```
114overrideUserAgent() {
115 return window.navigator.userAgent.replace(
116 /(Ferdi|Electron)\/\S+ \([^)]+\)/g,
117 ""
118 );
119}
120```
121
122If you want to change the user agent to a different one, you can simply return the String for the new user agent:
123
124```
125overrideUserAgent() {
126 return "Mozilla/2.02Gold (Win95; I)";
127}
128```
114 129
115### webview.js 130### webview.js
116The webview.js is the actual script that will be loaded into the webview. Here you can do whatever you want to do in order perfectly integrate the service into Ferdi. For convenience, we have provided a very simple set of functions to set unread message badges (`Ferdi.setBadge()`) and inject CSS files (`Ferdi.injectCSS()`). 131The webview.js is the actual script that will be loaded into the webview. Here you can do whatever you want to do in order perfectly integrate the service into Ferdi. For convenience, we have provided a very simple set of functions to set unread message badges (`Ferdi.setBadge()`) and inject CSS files (`Ferdi.injectCSS()`).