I ran into the problem that I need to track the installation/removal of an extension, but as it turns out, I can’t do that on the front-end side. I can only ask the Metamask developers to write some kind of message in the console so that I can track installation/deletion by it.
Now there is a problem: if you uninstall the extension and try to address any request to Metamask, without refreshing the page the browser thinks that “window.ethereum” exists. Also the installation situation: if you go to the site, install the extension and try any request, the browser will not see “window.ethereum” without reloading the page.
You may be interested in MetaMask Flask, where you may be able to develop what you are looking to do through a Snaps plug-in