things like glitchypastepen will automatically throw errors if you put non-head stuff in the head tag and non-body stuff in the body. I guess these are super old sites?
Anyways one possibility is to get an extension like dark mode, which always injects a link tag. and then append all this to the link tag (which will be in the head)