Skip to content

Workaround to fix URL opening in Office 365 #642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion recipes/office365-owa/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "office365-owa",
"name": "Office 365 Outlook",
"version": "1.7.3",
"version": "1.7.4",
"license": "MIT",
"aliases": [
"live.com",
Expand Down
34 changes: 34 additions & 0 deletions recipes/office365-owa/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down