diff options
author | Vijay A <vraravam@users.noreply.github.com> | 2022-05-15 15:01:36 -0500 |
---|---|---|
committer | Vijay Aravamudhan <vraravam@users.noreply.github.com> | 2022-05-15 15:08:54 -0500 |
commit | ddeaca3d6776d8828e8d4bf1e849d0f7097982f0 (patch) | |
tree | dd5fc3ed9691c31ed55ce1d9a1b7bb827ae4465e /recipes/slack/webview.js | |
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
Diffstat (limited to 'recipes/slack/webview.js')
-rw-r--r-- | recipes/slack/webview.js | 14 |
1 files changed, 14 insertions, 0 deletions
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 | }; |