Select a part of the viewport and compute the maximum contrast ratio
There may be a slight deviation because a monitor color profile is applied when the screen is captured.
In Chrome you can counteract that by changing chrome://flag 'Force color profile' to sRGB
v1.0.3 Using shadow root to prevent style mixture.
v1.0.5 Showing more color in a grid with contrast values
v1.0.6 Improved color selection