MetaMask / extension-provider

A module for allowing a WebExtension to access the web3 provider from an installed MetaMask instance
MIT License
68 stars 28 forks source link

I want to be able to connect to meta mask browser extension from a chrome extension tab loaded application #30

Open javaspeak opened 12 months ago

javaspeak commented 12 months ago

Greetings

I want to be able to connect to meta mask browser extension from a chrome extension tab loaded application.

However when I use a background script of the chrome extension to open my own extension app in a tab, it does not have access to the chrome namespace. The chrome variable is undefined.

i.e. in https://github.com/MetaMask/extension-provider/blob/master/index.js

this code will fail:

const metamaskPort = chrome.runtime.connect(currentMetaMaskId)

What I want to do is connect my wallet to the tab extension url which looks like this:

chrome-extension://oahhaapnfpkfnbgeopliehfgenifngde/tab.html#/register

i.e. I want the wallet connected to the chrome extension app and not the domain the content script happens to be on.

Thank you for your time