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 authored and Alphrag committed Nov 5, 2023
1 parent ab771b0 commit 96e2e64
Showing 1 changed file with 26 additions and 1 deletion.
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 96e2e64

Please sign in to comment.