aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/steamchat/webview.js
diff options
context:
space:
mode:
authorLibravatar André Oliveira <37463445+SpecialAro@users.noreply.github.com>2022-05-31 16:07:41 +0100
committerLibravatar GitHub <noreply@github.com>2022-05-31 16:07:41 +0100
commit804aafb265e93c50abcb4d2c28e0ddfab16a36bb (patch)
treed11dd6abab6c98b19b617c3c4de1815122fe2888 /recipes/steamchat/webview.js
parentChange of Proton Service URL (#36) (diff)
downloadferdium-recipes-804aafb265e93c50abcb4d2c28e0ddfab16a36bb.tar.gz
ferdium-recipes-804aafb265e93c50abcb4d2c28e0ddfab16a36bb.tar.zst
ferdium-recipes-804aafb265e93c50abcb4d2c28e0ddfab16a36bb.zip
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).
Diffstat (limited to 'recipes/steamchat/webview.js')
-rw-r--r--recipes/steamchat/webview.js20
1 files changed, 11 insertions, 9 deletions
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) => {
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 // 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
34 document.addEventListener('click', event => { 34 document.addEventListener('click', event => {
35 const link = event.target.closest('a[href^="http"]'); 35 const link = event.target.closest('a[href^="http"]');
36 const button = event.target.closest('button[title^="http"]');
36 37
37 if (link && link.getAttribute('target') === '_top') { 38 if (link || button) {
38 event.preventDefault(); 39 const url = link ? link.getAttribute('href') : button.getAttribute('title');
39 event.stopPropagation();
40 const url = link.getAttribute('href');
41 40
42 if (settings.trapLinkClicks === true) { 41 event.preventDefault();
43 window.location.href = url; 42 event.stopPropagation();
44 } else { 43
45 Ferdium.openNewWindow(url); 44 if (settings.trapLinkClicks === true) {
46 } 45 window.location.href = url;
46 } else {
47 Ferdium.openNewWindow(url);
48 }
47 } 49 }
48 }, true); 50 }, true);
49}; 51};