All I want is to click a button in the menubar to toggle a class.
If I am understanding this correctly, the menubar that you have mentioned here is not the menubar from the native MacOS, but the toolbar from the Safari browser as hinted in this context.
This project might be useful for your intended use case as described in the quesetion, which is a sample project of how to create a browser action that will show up on the browser toolbar and you may then potentially manipulate the content of the webpage from there onwards.
For more information on creating web extension you may also find MDN browser extension tutorials helpful.