From 804aafb265e93c50abcb4d2c28e0ddfab16a36bb Mon Sep 17 00:00:00 2001 From: André Oliveira <37463445+SpecialAro@users.noreply.github.com> Date: Tue, 31 May 2022 16:07:41 +0100 Subject: Fix open image in app or externally (instead of popup) (#37) Fix #195 on Ferdium-app which causes a problem when opening images inside the discord (and possibly zoom). --- recipes/discord/package.json | 2 +- recipes/discord/webview.js | 19 ++++++++++--------- recipes/skype/package.json | 2 +- recipes/skype/webview.js | 16 +++++++--------- recipes/steamchat/package.json | 2 +- recipes/steamchat/webview.js | 20 +++++++++++--------- recipes/zoom/package.json | 2 +- recipes/zoom/webview.js | 18 ++++++++++-------- 8 files changed, 42 insertions(+), 39 deletions(-) (limited to 'recipes') diff --git a/recipes/discord/package.json b/recipes/discord/package.json index e0c35aa..f5549d7 100644 --- a/recipes/discord/package.json +++ b/recipes/discord/package.json @@ -1,7 +1,7 @@ { "id": "discord", "name": "Discord", - "version": "1.7.3", + "version": "1.7.4", "license": "MIT", "config": { "serviceURL": "https://discordapp.com/login", diff --git a/recipes/discord/webview.js b/recipes/discord/webview.js index cadafb1..1255675 100644 --- a/recipes/discord/webview.js +++ b/recipes/discord/webview.js @@ -5,7 +5,6 @@ function _interopRequireDefault(obj) { } module.exports = (Ferdium, settings) => { - console.log('settings', settings); const getMessages = () => { let directCount = 0; const directCountPerServer = document.querySelectorAll( @@ -34,14 +33,16 @@ module.exports = (Ferdium, settings) => { if (link || button) { const url = link ? link.getAttribute('href') : button.getAttribute('title'); - - event.preventDefault(); - event.stopPropagation(); - - if (settings.trapLinkClicks === true) { - window.location.href = url; - } else { - Ferdium.openNewWindow(url); + + if (!Ferdium.isImage(url)) { + event.preventDefault(); + event.stopPropagation(); + + if (settings.trapLinkClicks === true) { + window.location.href = url; + } else { + Ferdium.openNewWindow(url); + } } } }, true); diff --git a/recipes/skype/package.json b/recipes/skype/package.json index 0a07ea3..247d9c5 100644 --- a/recipes/skype/package.json +++ b/recipes/skype/package.json @@ -1,7 +1,7 @@ { "id": "skype", "name": "Skype", - "version": "3.5.2", + "version": "3.5.3", "license": "MIT", "config": { "serviceURL": "https://web.skype.com/", diff --git a/recipes/skype/webview.js b/recipes/skype/webview.js index b317d14..db97d98 100644 --- a/recipes/skype/webview.js +++ b/recipes/skype/webview.js @@ -38,15 +38,13 @@ module.exports = (Ferdium, settings) => { if (link || button) { const url = link ? link.getAttribute('href') : button.getAttribute('title'); - if (url.includes('views/imgpsh_fullsize_anim')) { - event.preventDefault(); - event.stopPropagation(); - - if (settings.trapLinkClicks === true) { - window.location.href = url; - } else { - Ferdium.openNewWindow(url); - } + event.preventDefault(); + event.stopPropagation(); + + if (settings.trapLinkClicks === true) { + window.location.href = url; + } else { + Ferdium.openNewWindow(url); } } }, true); diff --git a/recipes/steamchat/package.json b/recipes/steamchat/package.json index 9489add..9123671 100644 --- a/recipes/steamchat/package.json +++ b/recipes/steamchat/package.json @@ -1,7 +1,7 @@ { "id": "steamchat", "name": "SteamChat", - "version": "1.4.2", + "version": "1.4.3", "license": "MIT", "config": { "serviceURL": "https://steamcommunity.com/chat", diff --git a/recipes/steamchat/webview.js b/recipes/steamchat/webview.js index 4e8519b..9cb6d64 100644 --- a/recipes/steamchat/webview.js +++ b/recipes/steamchat/webview.js @@ -33,17 +33,19 @@ module.exports = (Ferdium, settings) => { // 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 && link.getAttribute('target') === '_top') { - event.preventDefault(); - event.stopPropagation(); - const url = link.getAttribute('href'); + if (link || button) { + const url = link ? link.getAttribute('href') : button.getAttribute('title'); - if (settings.trapLinkClicks === true) { - window.location.href = url; - } else { - Ferdium.openNewWindow(url); - } + event.preventDefault(); + event.stopPropagation(); + + if (settings.trapLinkClicks === true) { + window.location.href = url; + } else { + Ferdium.openNewWindow(url); + } } }, true); }; diff --git a/recipes/zoom/package.json b/recipes/zoom/package.json index eb8f557..5357394 100644 --- a/recipes/zoom/package.json +++ b/recipes/zoom/package.json @@ -1,7 +1,7 @@ { "id": "zoom", "name": "Zoom", - "version": "1.3.2", + "version": "1.3.3", "license": "MIT", "config": { "serviceURL": "https://zoom.us/join", diff --git a/recipes/zoom/webview.js b/recipes/zoom/webview.js index 030c038..1255675 100644 --- a/recipes/zoom/webview.js +++ b/recipes/zoom/webview.js @@ -33,14 +33,16 @@ module.exports = (Ferdium, settings) => { if (link || button) { const url = link ? link.getAttribute('href') : button.getAttribute('title'); - - event.preventDefault(); - event.stopPropagation(); - - if (settings.trapLinkClicks === true) { - window.location.href = url; - } else { - Ferdium.openNewWindow(url); + + if (!Ferdium.isImage(url)) { + event.preventDefault(); + event.stopPropagation(); + + if (settings.trapLinkClicks === true) { + window.location.href = url; + } else { + Ferdium.openNewWindow(url); + } } } }, true); -- cgit v1.2.3-54-g00ecf