url from sender/tab, better per-extension errors (#44)
* url from sender/tab, better per-extension errors * Remove debug log
This commit is contained in:
parent
1a18a2eebb
commit
e7c6272e98
@ -2,7 +2,7 @@
|
||||
// This software may be modified and distributed under the terms
|
||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||
|
||||
import { InjectedAccount, InjectedAccountWithMeta, InjectedExtension, InjectedExtensionInfo, InjectedWindow, Unsubcall } from './types';
|
||||
import { InjectedAccount, InjectedAccountWithMeta, InjectedExtension, InjectedWindow, Unsubcall } from './types';
|
||||
|
||||
// our extension adaptor for other kinds of extensions
|
||||
import compatInjector from './compat';
|
||||
@ -44,9 +44,12 @@ export function web3Enable (originName: string): Promise<Array<InjectedExtension
|
||||
web3EnablePromise = compatInjector().then(() =>
|
||||
Promise.all(
|
||||
Object.entries(win.injectedWeb3).map(([name, { enable, version }]) =>
|
||||
Promise
|
||||
.all([Promise.resolve({ name, version }), enable(originName)])
|
||||
.catch(() => [{ name, version }, null] as [InjectedExtensionInfo, null])
|
||||
Promise.all([
|
||||
Promise.resolve({ name, version }),
|
||||
enable(originName).catch((error: Error) => {
|
||||
console.error(`Error initializing ${name}: ${error.message}`);
|
||||
})
|
||||
])
|
||||
)
|
||||
)
|
||||
.then((values) =>
|
||||
|
||||
@ -12,10 +12,7 @@
|
||||
},
|
||||
"content_scripts": [{
|
||||
"js": ["content.js"],
|
||||
"matches": [
|
||||
"https://polkadot.js.org/apps/*",
|
||||
"http://localhost:3000/*"
|
||||
],
|
||||
"matches": ["http://*/*", "https://*/*"],
|
||||
"run_at": "document_start"
|
||||
}],
|
||||
"icons": {
|
||||
|
||||
@ -27,7 +27,7 @@ export default function handler ({ id, message, request }: MessageRequest, port:
|
||||
const sender = port.sender as chrome.runtime.MessageSender;
|
||||
const from = isPopup
|
||||
? 'popup'
|
||||
: sender.tab && sender.tab.url;
|
||||
: (sender.tab && sender.tab.url) || sender.url;
|
||||
const source = `${from || FALLBACK_URL}: ${id}: ${message}`;
|
||||
|
||||
console.log(` [in] ${source}`); // :: ${JSON.stringify(request)}`);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user