I don't know where to start with this one. I assume it's a content script that loads a script somehow? But MetaMask doesn't add a script tag to the DOM, so I'm not sure.
Related: WHat's the easiest way to achieve this effect? (i.e. not necessarily how MetaMask does it)
Btw, I am following this tutorial for adding content scripts.