How to quickly change Background from dark to bright in Mail

The new dark mode introduced with Mojave has some issues with Mails where the author has used text highlighting (like, putting a yellow background behind a black text): This is going to be white on yellow in dark mode, and hence hardly readable. Worse even, there appears to be a trend where some people send mails with a black background in the first place, making them harder to read. Here is a way to quickly change that on a per-mail basis.

Basically, if you chose “Use dark backgrounds for messages” within the settings of Mail, you get an additional menu item in View – Message – Show with Light Background. Would it not be nice to have an option to trigger this menu item with a keyboard combination.

Here is a script that you can run using Better Touch Tool – I put it on Cmd+B (for background) for Mail. It switches back and forth between dark and light background. You’ll probably need to change the labels for your language: There’s a commented line that shows how to do it… For English, it’s probably “Message” instead of “E-Mail”, and “View” instead of “Darstellung.”

tell application "Mail" to activate

tell application "System Events"
	tell process "Mail"
		click menu item 1 ¬
			of menu "E-Mail" of menu item "E-Mail" of menu "Darstellung" of menu bar 1
		-- set xxx to name of every menu item of menu "Darstellung" of menu bar 1
	end tell
end tell