diff options
author | Arthur Huan <c.arthurh@outlook.com> | 2023-11-05 15:43:26 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-05 22:43:26 +0000 |
commit | c54985c89a8e9a5adf6c80790d217441f80fc946 (patch) | |
tree | 7bf9c114a5f0236cfcbe8b3cb5c2ab1069ca7292 /recipes/messenger/webview.js | |
parent | prevent pulling archived chats unread count (#452) (diff) | |
download | ferdium-recipes-c54985c89a8e9a5adf6c80790d217441f80fc946.tar.gz ferdium-recipes-c54985c89a8e9a5adf6c80790d217441f80fc946.tar.zst ferdium-recipes-c54985c89a8e9a5adf6c80790d217441f80fc946.zip |
Update Messenger link handling (#446)
Diffstat (limited to 'recipes/messenger/webview.js')
-rw-r--r-- | recipes/messenger/webview.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/recipes/messenger/webview.js b/recipes/messenger/webview.js index 39ea098..781436b 100644 --- a/recipes/messenger/webview.js +++ b/recipes/messenger/webview.js | |||
@@ -14,7 +14,7 @@ function hideInstallMessage() { | |||
14 | } | 14 | } |
15 | } | 15 | } |
16 | 16 | ||
17 | module.exports = Ferdium => { | 17 | module.exports = (Ferdium, settings) => { |
18 | const getMessages = () => { | 18 | const getMessages = () => { |
19 | let count = 0; | 19 | let count = 0; |
20 | let newMessengerUI = false; | 20 | let newMessengerUI = false; |
@@ -101,4 +101,29 @@ module.exports = Ferdium => { | |||
101 | return notification; | 101 | return notification; |
102 | }); | 102 | }); |
103 | } | 103 | } |
104 | |||
105 | document.addEventListener( | ||
106 | 'click', | ||
107 | event => { | ||
108 | const link = event.target.closest('a[href^="http"]'); | ||
109 | const button = event.target.closest('button[title^="http"]'); | ||
110 | |||
111 | if (link || button) { | ||
112 | const url = link | ||
113 | ? link.getAttribute('href') | ||
114 | : button.getAttribute('title'); | ||
115 | |||
116 | event.preventDefault(); | ||
117 | event.stopPropagation(); | ||
118 | |||
119 | if (url.includes('fbsbx.com') || settings.trapLinkClicks === true) { | ||
120 | // 'fbsbx.com is Facebook file hosting service. Always open file downloads in Ferdium. | ||
121 | window.location.href = url; | ||
122 | } else { | ||
123 | Ferdium.openNewWindow(url); | ||
124 | } | ||
125 | } | ||
126 | }, | ||
127 | true, | ||
128 | ); | ||
104 | }; | 129 | }; |