From ddeaca3d6776d8828e8d4bf1e849d0f7097982f0 Mon Sep 17 00:00:00 2001 From: Vijay A Date: Sun, 15 May 2022 15:01:36 -0500 Subject: Use a click-handler for slack to capture all click events and open in the same recipe webview --- recipes/discord/webview.js | 1 + recipes/skype/webview.js | 1 + recipes/slack/package.json | 2 +- recipes/slack/webview.js | 14 ++++++++++++++ recipes/steamchat/webview.js | 1 + recipes/zoom/webview.js | 1 + 6 files changed, 19 insertions(+), 1 deletion(-) (limited to 'recipes') 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 => { Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); + // 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 document.addEventListener('click', event => { const link = event.target.closest('a[href^="http"]'); 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 => { Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); Ferdium.injectJSUnsafe(_path.default.join(__dirname, 'webview-unsafe.js')); + // 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 document.addEventListener('click', event => { const link = event.target.closest('a[href^="http"]'); 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 @@ { "id": "slack", "name": "Slack", - "version": "1.4.0", + "version": "1.4.1", "license": "MIT", "config": { "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 => { }, 4000); Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); + + // 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 + document.addEventListener('click', event => { + const link = event.target.closest('a[href^="http"]'); + const button = event.target.closest('button[title^="http"]'); + + if (link || button) { + const url = link ? link.getAttribute('href') : button.getAttribute('title'); + + event.preventDefault(); + event.stopPropagation(); + window.location.href = url; + } + }, true); }; 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 => { Ferdium.loop(getMessages); + // 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 document.addEventListener('click', event => { const link = event.target.closest('a[href^="http"]'); 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 => { Ferdium.injectCSS(_path.default.join(__dirname, 'service.css')); + // 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 document.addEventListener('click', event => { const link = event.target.closest('a[href^="http"]'); const button = event.target.closest('button[title^="http"]'); -- cgit v1.2.3-70-g09d2