diff options
author | 2023-11-05 15:43:26 -0700 | |
---|---|---|
committer | 2023-11-05 22:43:26 +0000 | |
commit | c54985c89a8e9a5adf6c80790d217441f80fc946 (patch) | |
tree | 7bf9c114a5f0236cfcbe8b3cb5c2ab1069ca7292 /recipes/messenger | |
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')
-rw-r--r-- | recipes/messenger/package.json | 2 | ||||
-rw-r--r-- | recipes/messenger/webview.js | 27 |
2 files changed, 27 insertions, 2 deletions
diff --git a/recipes/messenger/package.json b/recipes/messenger/package.json index fc49dd9..a12065d 100644 --- a/recipes/messenger/package.json +++ b/recipes/messenger/package.json | |||
@@ -1,7 +1,7 @@ | |||
1 | { | 1 | { |
2 | "id": "messenger", | 2 | "id": "messenger", |
3 | "name": "Messenger", | 3 | "name": "Messenger", |
4 | "version": "1.8.1", | 4 | "version": "1.8.2", |
5 | "license": "MIT", | 5 | "license": "MIT", |
6 | "config": { | 6 | "config": { |
7 | "serviceURL": "https://messenger.com", | 7 | "serviceURL": "https://messenger.com", |
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 | }; |