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;
|
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) {
|
function performAction(targets, actionFn) {
|
||||||
if (targets.length === 0) return;
|
if (targets.length === 0) return;
|
||||||
var i = 0;
|
var i = 0;
|
||||||
@@ -204,12 +221,26 @@ window.OutlookRelook.Keyboard = (function () {
|
|||||||
}
|
}
|
||||||
var target = targets[i];
|
var target = targets[i];
|
||||||
i++;
|
i++;
|
||||||
// Click to select in OWA, then perform action
|
|
||||||
target.click();
|
// First, try to find the inline button without clicking the row.
|
||||||
|
// Hover to make OWA's inline action buttons appear.
|
||||||
|
triggerHover(target);
|
||||||
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
actionFn(target);
|
// Try inline button first (avoids opening the email in fill-screen mode)
|
||||||
setTimeout(processNext, 200);
|
var inlineHandled = actionFn(target);
|
||||||
}, 150);
|
|
||||||
|
// 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();
|
processNext();
|
||||||
}
|
}
|
||||||
@@ -217,42 +248,33 @@ window.OutlookRelook.Keyboard = (function () {
|
|||||||
function actionDelete(targets) {
|
function actionDelete(targets) {
|
||||||
performAction(targets, function (target) {
|
performAction(targets, function (target) {
|
||||||
var btn = findButton(target, 'Delete');
|
var btn = findButton(target, 'Delete');
|
||||||
if (btn) {
|
if (btn) { btn.click(); return true; }
|
||||||
btn.click();
|
console.warn('[Outlook Relook] Delete button not found');
|
||||||
} else {
|
return false;
|
||||||
console.warn('[Outlook Relook] Delete button not found');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function actionArchive(targets) {
|
function actionArchive(targets) {
|
||||||
performAction(targets, function (target) {
|
performAction(targets, function (target) {
|
||||||
var btn = findButton(target, 'Archive');
|
var btn = findButton(target, 'Archive');
|
||||||
if (btn) {
|
if (btn) { btn.click(); return true; }
|
||||||
btn.click();
|
console.warn('[Outlook Relook] Archive button not found');
|
||||||
} else {
|
return false;
|
||||||
console.warn('[Outlook Relook] Archive button not found');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function actionMarkReadUnread(targets) {
|
function actionMarkReadUnread(targets) {
|
||||||
// OWA uses a single toggle button "Read / Unread"
|
|
||||||
performAction(targets, function (target) {
|
performAction(targets, function (target) {
|
||||||
var btn = findButton(target, 'Read / Unread');
|
var btn = findButton(target, 'Read / Unread');
|
||||||
if (btn) {
|
if (btn) { btn.click(); return true; }
|
||||||
btn.click();
|
triggerContextMenuAction(target, /mark as read|mark as unread|read \/ unread/i);
|
||||||
} else {
|
return true; // context menu handles it
|
||||||
// Try context menu fallback
|
|
||||||
triggerContextMenuAction(target, /mark as read|mark as unread|read \/ unread/i);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function actionMove(targets) {
|
function actionMove(targets) {
|
||||||
if (targets.length > 0) {
|
if (targets.length > 0) {
|
||||||
// Select first target, then open move dialog
|
triggerHover(targets[0]);
|
||||||
targets[0].click();
|
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
var btn = findButton(targets[0], 'Move to');
|
var btn = findButton(targets[0], 'Move to');
|
||||||
if (btn) {
|
if (btn) {
|
||||||
@@ -268,22 +290,18 @@ window.OutlookRelook.Keyboard = (function () {
|
|||||||
performAction(targets, function (target) {
|
performAction(targets, function (target) {
|
||||||
var btn = findButton(target, 'Flag this message')
|
var btn = findButton(target, 'Flag this message')
|
||||||
|| findButton(target, 'Flag / Unflag');
|
|| findButton(target, 'Flag / Unflag');
|
||||||
if (btn) {
|
if (btn) { btn.click(); return true; }
|
||||||
btn.click();
|
console.warn('[Outlook Relook] Flag button not found');
|
||||||
} else {
|
return false;
|
||||||
console.warn('[Outlook Relook] Flag button not found');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function actionPin(targets) {
|
function actionPin(targets) {
|
||||||
performAction(targets, function (target) {
|
performAction(targets, function (target) {
|
||||||
var btn = findButton(target, 'Pin / Unpin');
|
var btn = findButton(target, 'Pin / Unpin');
|
||||||
if (btn) {
|
if (btn) { btn.click(); return true; }
|
||||||
btn.click();
|
console.warn('[Outlook Relook] Pin button not found');
|
||||||
} else {
|
return false;
|
||||||
console.warn('[Outlook Relook] Pin button not found');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user