Closed Jack-Works closed 4 years ago
I would recommend using our onboarding library for these purposes. Examples can be seen here
Hi @brad-decker .
We already noticed onboarding library. However Metamask cannot inject js into another extension's page ( something like chrome-extension://jkoeaghipilijlahjplgbfiocjhldnap/index.html#/wallets )
That's why we're wondering if there's any solution.
injecting js into another extension's page is not allowed by browser. There're other browser APIs could do so (some communication between extensions)
Right now we already able to use MetaMask inside Maskbook extension, and then provide MetaMask func on fb/Twitter. The only problem is within the extension's html page we don't know whether users installed Maskbook or not
I'm afraid the onboarding library doesn't work for another web extension.
https://github.com/MetaMask/metamask-onboarding/blob/master/src/index.ts#L154
In this line, you detect metamask by window.ethereum.isMetaMask
but window.ethereum
is not available in the web extension. This is why I'm using extension-provider
`(this library)
Hi @brad-decker - any thoughts?
I have been wondering whether this way is going to work.
If MetaMask is installed:
window
.window
.If MetaMask is not installed:
window
.You should also be able to detect whether MetaMask is installed using the error
event we have on this library's provider:
const createMetaMaskProvider = require('metamask-extension-provider')
const provider = createMetaMaskProvider()
provider.on('error', (error) => {
// Failed to connect to MetaMask, likely MetaMask is not installed.
})
@danfinlay thx it seems working well now :) @Jack-Works should we close this? would be great if you can make a document of this @danfinlay
Yeah I think we can close this now
🎭 Thx for all 🦊❤️
Right now finished the integration. however within our extension we have no idea whether user install MetaMask already or not. @danfinlay any good idea? Many thanks