diff options
author | 2022-05-15 15:01:36 -0500 | |
---|---|---|
committer | 2022-05-15 15:08:54 -0500 | |
commit | ddeaca3d6776d8828e8d4bf1e849d0f7097982f0 (patch) | |
tree | dd5fc3ed9691c31ed55ce1d9a1b7bb827ae4465e | |
parent | Upgrade 'pnpm' to '7.1.0' (diff) | |
download | ferdium-recipes-ddeaca3d6776d8828e8d4bf1e849d0f7097982f0.tar.gz ferdium-recipes-ddeaca3d6776d8828e8d4bf1e849d0f7097982f0.tar.zst ferdium-recipes-ddeaca3d6776d8828e8d4bf1e849d0f7097982f0.zip |
Use a click-handler for slack to capture all click events and open in the same recipe webview
-rw-r--r-- | recipes/discord/webview.js | 1 | ||||
-rw-r--r-- | recipes/skype/webview.js | 1 | ||||
-rw-r--r-- | recipes/slack/package.json | 2 | ||||
-rw-r--r-- | recipes/slack/webview.js | 14 | ||||
-rw-r--r-- | recipes/steamchat/webview.js | 1 | ||||
-rw-r--r-- | recipes/zoom/webview.js | 1 |
6 files changed, 19 insertions, 1 deletions
diff --git a/recipes/discord/webview.js b/recipes/discord/webview.js index 0dd0e38..7612d83 100644 --- a/recipes/discord/webview.js +++ b/recipes/discord/webview.js | |||
@@ -26,6 +26,7 @@ module.exports = Ferdium => { | |||
26 | 26 | ||
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 | document.addEventListener('click', event => { | 30 | document.addEventListener('click', event => { |
30 | const link = event.target.closest('a[href^="http"]'); | 31 | const link = event.target.closest('a[href^="http"]'); |
31 | const button = event.target.closest('button[title^="http"]'); | 32 | const button = event.target.closest('button[title^="http"]'); |
diff --git a/recipes/skype/webview.js b/recipes/skype/webview.js index 47b6f27..23e6919 100644 --- a/recipes/skype/webview.js +++ b/recipes/skype/webview.js | |||
@@ -30,6 +30,7 @@ module.exports = Ferdium => { | |||
30 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | 30 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); |
31 | Ferdium.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js')); | 31 | Ferdium.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js')); |
32 | 32 | ||
33 | // 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 | ||
33 | document.addEventListener('click', event => { | 34 | document.addEventListener('click', event => { |
34 | const link = event.target.closest('a[href^="http"]'); | 35 | const link = event.target.closest('a[href^="http"]'); |
35 | const button = event.target.closest('button[title^="http"]'); | 36 | const button = event.target.closest('button[title^="http"]'); |
diff --git a/recipes/slack/package.json b/recipes/slack/package.json index 5420c5b..6d18dac 100644 --- a/recipes/slack/package.json +++ b/recipes/slack/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "slack", | 2 | "id": "slack", |
3 | "name": "Slack", | 3 | "name": "Slack", |
4 | "version": "1.4.0", | 4 | "version": "1.4.1", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://{teamId}.slack.com", | 7 | "serviceURL": "https://{teamId}.slack.com", |
diff --git a/recipes/slack/webview.js b/recipes/slack/webview.js index b3722f0..652b586 100644 --- a/recipes/slack/webview.js +++ b/recipes/slack/webview.js | |||
@@ -75,4 +75,18 @@ module.exports = Ferdium => { | |||
75 | }, 4000); | 75 | }, 4000); |
76 | 76 | ||
77 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); | 77 | Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); |
78 | |||
79 | // 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 | ||
80 | document.addEventListener('click', event => { | ||
81 | const link = event.target.closest('a[href^="http"]'); | ||
82 | const button = event.target.closest('button[title^="http"]'); | ||
83 | |||
84 | if (link || button) { | ||
85 | const url = link ? link.getAttribute('href') : button.getAttribute('title'); | ||
86 | |||
87 | event.preventDefault(); | ||
88 | event.stopPropagation(); | ||
89 | window.location.href = url; | ||
90 | } | ||
91 | }, true); | ||
78 | }; | 92 | }; |
diff --git a/recipes/steamchat/webview.js b/recipes/steamchat/webview.js index 1188c71..3773bad 100644 --- a/recipes/steamchat/webview.js +++ b/recipes/steamchat/webview.js | |||
@@ -30,6 +30,7 @@ module.exports = Ferdium => { | |||
30 | 30 | ||
31 | Ferdium.loop(getMessages); | 31 | Ferdium.loop(getMessages); |
32 | 32 | ||
33 | // 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 | ||
33 | document.addEventListener('click', event => { | 34 | document.addEventListener('click', event => { |
34 | const link = event.target.closest('a[href^="http"]'); | 35 | const link = event.target.closest('a[href^="http"]'); |
35 | 36 | ||
diff --git a/recipes/zoom/webview.js b/recipes/zoom/webview.js index 0dd0e38..7612d83 100644 --- a/recipes/zoom/webview.js +++ b/recipes/zoom/webview.js | |||
@@ -26,6 +26,7 @@ module.exports = Ferdium => { | |||
26 | 26 | ||
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 | document.addEventListener('click', event => { | 30 | document.addEventListener('click', event => { |
30 | const link = event.target.closest('a[href^="http"]'); | 31 | const link = event.target.closest('a[href^="http"]'); |
31 | const button = event.target.closest('button[title^="http"]'); | 32 | const button = event.target.closest('button[title^="http"]'); |