Programmatically add DeFi sites to list of connected sites?

Hi folks,

I’m working on a crawler for DeFi sites and as part of that, I’m trying to manipulate MetaMask’s internal state so that a given DeFi site is already “connected” to MetaMask and I no longer have to click on the “connect my wallet” button.

Judging by MetaMask’s source code, there are API functions like addPermittedAccount that seem to do what I want but I don’t know if that’s the right way to go about it. How can I add a DeFi site like uniswap to MetaMask’s internal list of connected sites so that I don’t have to click the “connect my wallet” button when first visiting uniswap?