I was trying to research how MetaMask and other wallets inject their provider into window.ethereum but could not find much information on this. Every source I looked at seems to be more concerned with how to connect to this provider, which is fairly easy, rather than how to inject it into the browser. If anyone here has had an experience of trying to build your own MetaMask or working on this issue in general, your help will be much appreciated!
And how can we create a provider for window.ethereum ?