fix: hover to reveal inline buttons instead of clicking rows, prevents fill-screen open
This commit is contained in:
@@ -194,6 +194,23 @@ window.OutlookRelook.Keyboard = (function () {
|
||||
return btn;
|
||||
}
|
||||
|
||||
// Simulate hover on a message row to make OWA's inline action buttons appear
|
||||
function triggerHover(target) {
|
||||
var rect = target.getBoundingClientRect();
|
||||
var enterEvent = new MouseEvent('mouseenter', {
|
||||
bubbles: true, cancelable: true,
|
||||
clientX: rect.x + rect.width - 30,
|
||||
clientY: rect.y + rect.height / 2,
|
||||
});
|
||||
var overEvent = new MouseEvent('mouseover', {
|
||||
bubbles: true, cancelable: true,
|
||||
clientX: rect.x + rect.width - 30,
|
||||
clientY: rect.y + rect.height / 2,
|
||||
});
|
||||
target.dispatchEvent(enterEvent);
|
||||
target.dispatchEvent(overEvent);
|
||||
}
|
||||
|
||||
function performAction(targets, actionFn) {
|
||||
if (targets.length === 0) return;
|
||||
var i = 0;
|
||||
@@ -204,12 +221,26 @@ window.OutlookRelook.Keyboard = (function () {
|
||||
}
|
||||
var target = targets[i];
|
||||
i++;
|
||||
// Click to select in OWA, then perform action
|
||||
|
||||
// First, try to find the inline button without clicking the row.
|
||||
// Hover to make OWA's inline action buttons appear.
|
||||
triggerHover(target);
|
||||
|
||||
setTimeout(function () {
|
||||
// Try inline button first (avoids opening the email in fill-screen mode)
|
||||
var inlineHandled = actionFn(target);
|
||||
|
||||
// If inline button wasn't found, fall back to clicking the row + toolbar
|
||||
if (inlineHandled === false) {
|
||||
target.click();
|
||||
setTimeout(function () {
|
||||
actionFn(target);
|
||||
setTimeout(processNext, 200);
|
||||
}, 150);
|
||||
} else {
|
||||
setTimeout(processNext, 200);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
processNext();
|
||||
}
|
||||
@@ -217,42 +248,33 @@ window.OutlookRelook.Keyboard = (function () {
|
||||
function actionDelete(targets) {
|
||||
performAction(targets, function (target) {
|
||||
var btn = findButton(target, 'Delete');
|
||||
if (btn) {
|
||||
btn.click();
|
||||
} else {
|
||||
if (btn) { btn.click(); return true; }
|
||||
console.warn('[Outlook Relook] Delete button not found');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function actionArchive(targets) {
|
||||
performAction(targets, function (target) {
|
||||
var btn = findButton(target, 'Archive');
|
||||
if (btn) {
|
||||
btn.click();
|
||||
} else {
|
||||
if (btn) { btn.click(); return true; }
|
||||
console.warn('[Outlook Relook] Archive button not found');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function actionMarkReadUnread(targets) {
|
||||
// OWA uses a single toggle button "Read / Unread"
|
||||
performAction(targets, function (target) {
|
||||
var btn = findButton(target, 'Read / Unread');
|
||||
if (btn) {
|
||||
btn.click();
|
||||
} else {
|
||||
// Try context menu fallback
|
||||
if (btn) { btn.click(); return true; }
|
||||
triggerContextMenuAction(target, /mark as read|mark as unread|read \/ unread/i);
|
||||
}
|
||||
return true; // context menu handles it
|
||||
});
|
||||
}
|
||||
|
||||
function actionMove(targets) {
|
||||
if (targets.length > 0) {
|
||||
// Select first target, then open move dialog
|
||||
targets[0].click();
|
||||
triggerHover(targets[0]);
|
||||
setTimeout(function () {
|
||||
var btn = findButton(targets[0], 'Move to');
|
||||
if (btn) {
|
||||
@@ -268,22 +290,18 @@ window.OutlookRelook.Keyboard = (function () {
|
||||
performAction(targets, function (target) {
|
||||
var btn = findButton(target, 'Flag this message')
|
||||
|| findButton(target, 'Flag / Unflag');
|
||||
if (btn) {
|
||||
btn.click();
|
||||
} else {
|
||||
if (btn) { btn.click(); return true; }
|
||||
console.warn('[Outlook Relook] Flag button not found');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
function actionPin(targets) {
|
||||
performAction(targets, function (target) {
|
||||
var btn = findButton(target, 'Pin / Unpin');
|
||||
if (btn) {
|
||||
btn.click();
|
||||
} else {
|
||||
if (btn) { btn.click(); return true; }
|
||||
console.warn('[Outlook Relook] Pin button not found');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user