I came across this on Twitter:
http://shapeof.com/archives/2018/6/dark_mode_swap.html
UPDATE: The original source for this script