From f11775522b7237ecc413e2018306aa56a75caec4 Mon Sep 17 00:00:00 2001 From: Arthur Huan Date: Mon, 9 Jun 2025 12:44:50 +0800 Subject: [PATCH] Workaround to fix URL opening behavior --- recipes/office365-owa/package.json | 2 +- recipes/office365-owa/webview.js | 34 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/recipes/office365-owa/package.json b/recipes/office365-owa/package.json index edba1c697..cbd975054 100644 --- a/recipes/office365-owa/package.json +++ b/recipes/office365-owa/package.json @@ -1,7 +1,7 @@ { "id": "office365-owa", "name": "Office 365 Outlook", - "version": "1.7.3", + "version": "1.7.4", "license": "MIT", "aliases": [ "live.com", diff --git a/recipes/office365-owa/webview.js b/recipes/office365-owa/webview.js index 8deff398d..2f4aeaac3 100644 --- a/recipes/office365-owa/webview.js +++ b/recipes/office365-owa/webview.js @@ -23,6 +23,40 @@ module.exports = (Ferdium, settings) => { return unreadCount; }; + // adapted from the franz-custom-website recipe, for opening + // links according to the user's preference (Ferdium/ext.browser) + document.addEventListener( + 'click', + event => { + const link = event.target.closest('a'); + const button = event.target.closest('button'); + + if (link || button) { + const url = link + ? link.getAttribute('href') + : button.getAttribute('title'); + + // check if the URL is relative or absolute + if (url.startsWith('/')) { + return; + } + + // check if we have a valid URL that is not a script nor an image: + if (url && url !== '#' && !Ferdium.isImage(link)) { + event.preventDefault(); + event.stopPropagation(); + + if (settings.trapLinkClicks === true) { + window.location.href = url; + } else { + Ferdium.openNewWindow(url); + } + } + } + }, + true, + ); + const getMessages = () => { let directUnreadCount = 0; let indirectUnreadCount = 0;