Provides a set of helper functions to integrate the recipe into Franz.
Validate if the given URL is a valid service instance.
string
URL
// RocketChat integration
module.exports = Franz => class RocketChat extends Franz {
async validateUrl(url) {
try {
const resp = await window.fetch(`${url}/api/info`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});
const data = await resp.json();
return Object.hasOwnProperty.call(data, 'version');
} catch (err) {
console.error(err);
}
return false;
}
};
Validate if the given URL is a valid service instance.
Boolean
// Discord integration
module.exports = Franz => class Discord extends Franz {
overrideUserAgent() {
const useragent = window.navigator.userAgent;
// Quick and dirty hackfix
const parts = useragent.split('(KHTML, like Gecko)');
return parts.join('(KHTML, like Gecko) discord/0.0.248').replace('Electron', 'Discord').replace('Franz', 'Discord');
}
};
Franz recipes can hook into the electron webview events to trigger custom functions.
This is necessary for services like TweetDeck where custom URL forwarding is needed during login.
module.exports = Franz => class Tweetdeck extends Franz {
events = {
'did-get-redirect-request': '_redirectFix',
}
_redirectFix(event) {
if (event.newURL !== undefined && event.oldURL !== undefined && event.isMainFrame) {
if (event.isMainFrame) {
setTimeout(() => this.send('redirect-url', event.newURL), 100);
event.preventDefault();
}
}
}
};