Skip to content

Commit

Permalink
Update Messenger link handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Huan committed Oct 22, 2023
1 parent 5438c46 commit 7ce40f0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
2 changes: 1 addition & 1 deletion recipes/messenger/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "messenger",
"name": "Messenger",
"version": "1.8.0",
"version": "1.8.1",
"license": "MIT",
"config": {
"serviceURL": "https://messenger.com",
Expand Down
27 changes: 26 additions & 1 deletion recipes/messenger/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function hideInstallMessage() {
}
}

module.exports = Ferdium => {
module.exports = (Ferdium, settings) => {
const getMessages = () => {
let count = 0;
let newMessengerUI = false;
Expand Down Expand Up @@ -101,4 +101,29 @@ module.exports = Ferdium => {
return notification;
});
}

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();

if (url.includes('fbsbx.com') || settings.trapLinkClicks === true) {
// 'fbsbx.com is Facebook file hosting service. Always open file downloads in Ferdium.
window.location.href = url;
} else {
Ferdium.openNewWindow(url);
}
}
},
true,
);
};

0 comments on commit 7ce40f0

Please sign in to comment.