aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/discord
diff options
context:
space:
mode:
authorLibravatar MCMXC <16797721+mcmxcdev@users.noreply.github.com>2023-07-26 06:29:03 -0600
committerLibravatar GitHub <noreply@github.com>2023-07-26 17:59:03 +0530
commit9b8f01716774a960073e944823ab727cc867a8f6 (patch)
tree732b83770baa78f5cf12776aaa33ce65bebfa418 /recipes/discord
parentAdd Excalidraw recipe (#393) (diff)
downloadferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.gz
ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.tar.zst
ferdium-recipes-9b8f01716774a960073e944823ab727cc867a8f6.zip
chore: improve lint setup (#397)
- update eslint config to closely mirror the ones from ferdium-app - add .eslintignore - opt in to eslint `reportUnusedDisableDirectives` config option - remove `trailingComma: all` from `prettier` config which is default in `prettier` v3 - autofix or disable a lot of lint issues throughout codebase - add `volta` configuration to `package.json` to autoload correct `node` and `pnpm` versions - upgrade all `eslint` and `prettier` related dependencies to latest - update lint:fix npm script - reformat touched files with prettier - bumped up minor version for all recipes that have changes - introduced injection of 'service.css' where it was missing in many recipes --------- Co-authored-by: Vijay A <vraravam@users.noreply.github.com>
Diffstat (limited to 'recipes/discord')
-rw-r--r--recipes/discord/index.js18
-rw-r--r--recipes/discord/package.json2
-rw-r--r--recipes/discord/webview.js61
3 files changed, 46 insertions, 35 deletions
diff --git a/recipes/discord/index.js b/recipes/discord/index.js
index cd65352..e47dd76 100644
--- a/recipes/discord/index.js
+++ b/recipes/discord/index.js
@@ -1,8 +1,10 @@
1module.exports = Ferdium => class Discord extends Ferdium { 1module.exports = Ferdium =>
2 overrideUserAgent() { 2 class Discord extends Ferdium {
3 return window.navigator.userAgent.replace('(KHTML, like Gecko)', '(KHTML, like Gecko) discord/0.0.250') 3 overrideUserAgent() {
4 .replace('Electron', 'Discord') 4 return window.navigator.userAgent
5 .replace('Ferdium', 'Discord') 5 .replace('(KHTML, like Gecko)', '(KHTML, like Gecko) discord/0.0.250')
6 .replace('Apple Mac OS X', 'Intel Mac OS X'); 6 .replace('Electron', 'Discord')
7 } 7 .replace('Ferdium', 'Discord')
8}; 8 .replace('Apple Mac OS X', 'Intel Mac OS X');
9 }
10 };
diff --git a/recipes/discord/package.json b/recipes/discord/package.json
index 59cf22a..aed5e15 100644
--- a/recipes/discord/package.json
+++ b/recipes/discord/package.json
@@ -1,7 +1,7 @@
1{ 1{
2 "id": "discord", 2 "id": "discord",
3 "name": "Discord", 3 "name": "Discord",
4 "version": "1.7.10", 4 "version": "1.8.0",
5 "license": "MIT", 5 "license": "MIT",
6 "config": { 6 "config": {
7 "serviceURL": "https://discord.com/login", 7 "serviceURL": "https://discord.com/login",
diff --git a/recipes/discord/webview.js b/recipes/discord/webview.js
index c0c764d..ef56336 100644
--- a/recipes/discord/webview.js
+++ b/recipes/discord/webview.js
@@ -1,9 +1,9 @@
1const _path = _interopRequireDefault(require('path'));
2
3function _interopRequireDefault(obj) { 1function _interopRequireDefault(obj) {
4 return obj && obj.__esModule ? obj : { default: obj }; 2 return obj && obj.__esModule ? obj : { default: obj };
5} 3}
6 4
5const _path = _interopRequireDefault(require('path'));
6
7module.exports = (Ferdium, settings) => { 7module.exports = (Ferdium, settings) => {
8 const getMessages = () => { 8 const getMessages = () => {
9 let directCount = 0; 9 let directCount = 0;
@@ -27,30 +27,39 @@ module.exports = (Ferdium, settings) => {
27 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); 27 Ferdium.injectCSS(_path.default.join(__dirname, 'service.css'));
28 28
29 // TODO: See how this can be moved into the main ferdium app and sent as an ipc message for opening with a new window or same Ferdium recipe's webview based on user's preferences 29 // TODO: See how this can be moved into the main ferdium app and sent as an ipc message for opening with a new window or same Ferdium recipe's webview based on user's preferences
30 document.addEventListener('click', event => { 30 document.addEventListener(
31 const link = event.target.closest('a[href^="http"]'); 31 'click',
32 const button = event.target.closest('button[title^="http"]'); 32 event => {
33 33 const link = event.target.closest('a[href^="http"]');
34 if (link || button) { 34 const button = event.target.closest('button[title^="http"]');
35 const url = link ? link.getAttribute('href') : button.getAttribute('title'); 35
36 const skipDomains = [/^https:\/\/discordapp\.com\/channels\//i, /^https:\/\/discord\.com\/channels\//i]; 36 if (link || button) {
37 37 const url = link
38 let stayInsideDiscord; 38 ? link.getAttribute('href')
39 skipDomains.every(skipDomain => { 39 : button.getAttribute('title');
40 stayInsideDiscord = skipDomain.test(url); 40 const skipDomains = [
41 return !stayInsideDiscord; 41 /^https:\/\/discordapp\.com\/channels\//i,
42 }); 42 /^https:\/\/discord\.com\/channels\//i,
43 43 ];
44 if (!Ferdium.isImage(link) && !stayInsideDiscord) { 44
45 event.preventDefault(); 45 let stayInsideDiscord;
46 event.stopPropagation(); 46 skipDomains.every(skipDomain => {
47 47 stayInsideDiscord = skipDomain.test(url);
48 if (settings.trapLinkClicks === true) { 48 return !stayInsideDiscord;
49 window.location.href = url; 49 });
50 } else { 50
51 Ferdium.openNewWindow(url); 51 if (!Ferdium.isImage(link) && !stayInsideDiscord) {
52 event.preventDefault();
53 event.stopPropagation();
54
55 if (settings.trapLinkClicks === true) {
56 window.location.href = url;
57 } else {
58 Ferdium.openNewWindow(url);
59 }
52 } 60 }
53 } 61 }
54 } 62 },
55 }, true); 63 true,
64 );
56}; 65};