How can I add a custom class to every 2nd message?

Hi ziptofaf welcome to the forum

I’m not convinced that any class attributes need to be inserted into the DOM and I think there is a good chance that satisfactory results can be obtained purely by using the correct CSS selectors.

For example, this “works” somewhat except “small action” posts may make it a bit off from what you’re wanting.

div.post-stream > div:nth-child(odd) {
  background-color: #bde;
}