Programmatically turning on/off DNS over HTTPS

Some of the most recent Fireofox versions let you enable DNS over https. Since I need to switch this feature on and off (because, for example, I don’t want to use it when I’m using at the same time a VPN) I want to create a simple button that turns on/off the setting. No problem for the button, but I couldn’t find how I can enable and disable DoH programmatically. Can you help me?