Skip to content

Instantly share code, notes, and snippets.

@fortserious
Last active April 23, 2024 16:23
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fortserious/aee38888a9c672c27682fa43940588fa to your computer and use it in GitHub Desktop.
Save fortserious/aee38888a9c672c27682fa43940588fa to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name outlook quick actions hotfix
// @namespace www.rossdoran.com
// @version 1.7
// @description m$.gfy
// @match https://outlook.office.com/mail/*
// @match https://outlook.live.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @run-at document-start
// ==/UserScript==
var hideRibbon = false; // switch to true if you want to hide the ribbon, or false if you want the ribbon to be shown
var ribbonCSS = hideRibbon ? " .HIqgw.n0tDR, #RibbonRoot { display: none !important; height:0px !important; }" : "";
// custom style
$('head').append(`<style type="text/css">
.nloVY.pz2Jt .bx9dt { min-width: -2px !important; }` + ribbonCSS +
`</style>`);
waitForKeyElements (".WP8_u .UWVIR", moveQuickActions);
waitForKeyElements(".QpoLy", moveDeleteAction); // comment out this line to keep the delete quick action on the right
waitForKeyElements(".C2IG3.LPIso.oTkSL.iDEcr.wk4Sg", navigateToInbox); // i can't fathom why this is necessary, but this line makes the Inbox link return to your inbox, as it should
function navigateToInbox(elem)
{
$(elem).click(function()
{
$("button[aria-label='Close']").click();
}
);
}
function moveDeleteAction(elem)
{
var elem = $(elem);
var parent = elem.closest(`.hDNlA.lHRXq.iZbPU.JCRRb.G1NES,
.hDNlA.lHRXq.IjQyD.JCRRb.G1NES,
.hDNlA.lHRXq.epBmH.IMyk_,
.zKDWD.YbB6r.IKvQi.IjQyD.JCRRb.cSOXK.G1NES,
.zKDWD.YbB6r.IKvQi.IjQyD.JCRRb.G1NES,
.zKDWD.YbB6r.IKvQi.iZbPU.JCRRb.G1NES,
.zKDWD.YbB6r.IKvQi.iZbPU.wZij3.G1NES,
.zKDWD.YbB6r.IKvQi.IjQyD.EhiOs.wZij3.G1NES,
.zKDWD.YbB6r.IKvQi.epBmH.EhiOs,
.zKDWD.IKvQi.IjQyD.JCRRb.G1NES,
.zKDWD.IKvQi.iZbPU.JCRRb._KLsp.G1NES,
.zKDWD.IKvQi.iZbPU.JCRRb.G1NES,
.zKDWD.IKvQi.gPZmZ.JCRRb.G1NES,
.zKDWD.IKvQi.epBmH,
.hDNlA.lHRXq.gPZmZ.JCRRb.G1NES
`); // different for pinned, flagged, returning to inbox after deleting, etc.
if (parent.length > 0)
{
var newParent = parent.find(`
.XG5Jd.y1E5h.zItCb,
.XG5Jd.hQj7T,
.OD8Ue.hQj7T,
.xc0ZS.hQj7T
`).children().first();
if (newParent.length > 0)
{
elem.detach().appendTo(newParent);
}
}
}
function moveQuickActions(elem)
{
var elem = $(elem);
var parent = elem.closest(
`.XG5Jd.hQj7T,
.xc0ZS.hQj7T,
.OD8Ue.hQj7T`); // parent element of left items
if (parent.length > 0)
{
var newParent = parent.children().first(); // append to first child of left item parent
if (newParent.length > 0)
{
elem.detach().appendTo(newParent);
}
}
}
@Peppins32
Copy link

Yes it's like this with tampermonkey :/

ps. i still see the quickaction buttons on the left of every msg and not like was before

@NinjaDuckie
Copy link

As of April 3rd, Chrome 123.0.6312.86 x64, outlook.live.com has shifted all the quick actions back to the right side regardless of the script running.

@archnila
Copy link

archnila commented Apr 5, 2024

As of April 3rd, Chrome 123.0.6312.86 x64, outlook.live.com has shifted all the quick actions back to the right side regardless of the script running.

Can confirm. Outlook trying to make life harder for us...

@fortserious
Copy link
Author

Thank you for your patience, folks. v1.2 has been updated with the new class names. It's working for me on Chrome/Firefox on https://outlook.office.com/mail/ and https://outlook.live.com/ (but I can only test the drafts folder on live).

@Peppins32
Copy link

For me are still on the right on ff, bha..

@fortserious
Copy link
Author

image

I'm sorry Peppins, I don't know what could be happening! I downloaded the esr branch of Firefox and it's still working for me on Firefox 115.9.1esr (32-bit). What's the URL you use to access outlook? Do you see the green toggle, and the red icon showing the number of times the script ran? I'm determined to fix this for you lol.

@NewVicious
Copy link

image

I have upgraded to 1.2 and compared to the image you show I get a 2 instead of 3 and now I don't get the quick actions, I only get the delete button.

URL
https://outlook.live.com/mail/
Chrome
Versión 123.0.6312.106 (Build oficial) (64 bits)

@fortserious
Copy link
Author

That makes sense. I've updated the script and that should no longer be hidden for you. I'm not sure if they will move to the left or right though.

@Peppins32
Copy link

Peppins32 commented Apr 5, 2024

I'm sorry Peppins, I don't know what could be happening! I downloaded the esr branch of Firefox and it's still working for me on Firefox 115.9.1esr (32-bit). What's the URL you use to access outlook? Do you see the green toggle, and the red icon showing the number of times the script ran? I'm determined to fix this for you lol.

Wait i edited my msg because i've noticed that tamper was disabled lol

The script work but i don't see quick action at all (on the left) and just the delete button on the right...

@fortserious
Copy link
Author

Are you using 1.2 or 1.3?

@NewVicious
Copy link

image

With 1.3 they appear but remain the same on the right side.

@Peppins32
Copy link

Are you using 1.2 or 1.3?

Was with 1.2, updated now with 1.3 and i confirm what Vicious said above.

@fortserious
Copy link
Author

The fact that they disappeared on the right is interesting. It means those right-side classes are correct, but the ones on the left aren't.

This is tricky without having access to your browser/computer, but I can try. When you right click -> inspect element in Chrome (or Inspect in Firefox), you can see specific class names of elements. When you hover over the names of them, it will highlight the DOM elements.

We're looking for two specific class names.

  1. The name of the main parent item for the row (it will have a tabindex of -1).

image

  1. The name of the child of the container (it should be the first child of the second child of #1.

image

If you can get me those class names, I can add those to the script and see if that works. (If you screenshot, be careful not to share any personal information!)

(Outlook live doesn't allow right clicking, so you may need to type "document.addEventListener('contextmenu', event => event.stopPropagation(), true);" into the console in order to enable right clicking again. In Firefox, I had to enter the phrase "allow pasting" in order to do this.)

@Peppins32
Copy link

Apparently the icon are toooo on the left, check this:

immagine

This is for example to check read/unread and it work if i click the small button xD

@fortserious
Copy link
Author

Perfect, that's all I need. I've updated the script, let me know if anything's different!

@Peppins32
Copy link

Icons are back but still on the right, and there is stil the small read check too far on the left like above.

@NewVicious
Copy link

image
image

hope they can be useful to you

I don't know what made me open an incognito window and use another email that I have in outlook and when I open it I see that it works, it shows me the icons on the left side.

image

But when I log out and switch to my normal account even in incognito the icons appear on the right side.

Reviewing the classes in both accounts I realize that they are the same and I said then why it does not work, it is because both accounts have different configurations and I know which is the one that causes that they do not move to where they should and it is this option.

image

I had the Text Size and Spacing set to Medium, changed it to Large and they moved to the left and now no matter what I choose they stay where the buttons should be, although sometimes the delete button is set to the right in some messages.

I hope this solution will help someone else.

@fortserious
Copy link
Author

That's great detective work, thanks for doing that! I've updated v1.5 with the new classes, let me know if you see a change.

I'm starting to think it would be a better idea to try and find the elements based on aria-labels or something that's more human readable and less likely to change. The structure generally stays the same, it's just that every time they push an update there's some new obfuscated class name that gets replaced.

Ideally it would be robust enough to handle that. Maybe one day!

@Peppins32
Copy link

Still on the right for me, also changing text dimension doesn't change anything (i mean for the icons).

@fortserious
Copy link
Author

@Peppins32 I'm waiting for my grill to preheat and I just zoomed in to your pic and noticed I accidentally uncapitalized the T in last character of the 2nd class. I have 1.6 up for you, and I'm feeling really good about it.

@NewVicious
Copy link

image

I still have 1.3 installed when I went through the configuration options, try the first 3 options to see which one fixes it (change any option, save and reload the page).

I just upgraded to 1.5 and the icons stay on the left side.

@Pinguimbera
Copy link

Thanks again for new version! Works fine 05 april 2024

@Peppins32
Copy link

Peppins32 commented Apr 6, 2024

@Peppins32 I'm waiting for my grill to preheat and I just zoomed in to your pic and noticed I accidentally uncapitalized the T in last character of the 2nd class. I have 1.6 up for you, and I'm feeling really good about it.

Oh god, finally this time worked!!!

There is just a little issue. If you have some pinned message, the delete button are still on the right with "<div class="QpoLy">".

@fortserious
Copy link
Author

Glad to hear it! Yeah that makes sense. If you do the same inspect elements trick with the pinned message and paste the classname here I can cover that case as well.

@Peppins32
Copy link

Read above, unfortunately the div class appear only when i'm with mouse on it (i mean the > that allow you to see more lines).

@fortserious
Copy link
Author

Read above, unfortunately the div class appear only when i'm with mouse on it (i mean the > that allow you to see more lines).

Yes, that's true. It's a little tricky, but if you position the devtools window carefully, you can arrange it so that your mouse cursor will be on top of it when you click on Inspect, which will keep the hovered element in focus.

@Peppins32
Copy link

I didi it, mouse + arrows xD

immagine

@fortserious
Copy link
Author

Updated 1.7 with the new class.

@Peppins32
Copy link

Peppins32 commented Apr 7, 2024

Work but this happened:

immagine

As you can see, buttons aren't close to each other :/

Why there are spaces?

@NinjaDuckie
Copy link

Sorry, was abroad on holiday. Updated to latest version, seems perfect once again. @Peppins32 - I had a space between pin and delete when first loading the page, which went away after waiting a little while. I think that might be unavoidable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment