How do I detect if a user has Mac OS high contrast accessibility settings enabled?

Iam afraid it is not possible its at this moment.

The feature in Objective-C to determine if the accessibility mode is active (boolean AXAPIEnabled(void);) has been deprecated as of 10.9 with no indication that there is a replacement. You can see it on the Apple Developer site. By extension, if developers at that level of the system no longer have access, I expect web developers would also be restricted (just as AppleScript writers seem to not have access).

In general, testing for the presence of assistive technology or activation of assistive features is frowned upon by the users who need it most. It creates the very real risk of both well-intentioned developers breaking these features (perhaps by un-verting the page) and also of allowing bad actors to determine somebody's personal health information.

Altought it might come in future as its in stage 5 (proposal) https://drafts.csswg.org/mediaqueries-5/#prefers-contrast

Other than that Iam afraid you are facing dead end.