@@ -2,8 +2,6 @@ import browser from 'webextension-polyfill'
2
2
import { stream } from '@thi.ng/rstream'
3
3
import { getSiteMetadata } from '@fluent-wallet/site-metadata'
4
4
5
- let INPAGE_INJECTED = false
6
-
7
5
function _retry ( ) {
8
6
let retryTimeout = 100
9
7
if ( CONNECT_RETRY_COUNT >= 10 ) {
@@ -23,22 +21,6 @@ function _retry() {
23
21
setTimeout ( setup , retryTimeout )
24
22
}
25
23
26
- function injectInpage ( content ) {
27
- try {
28
- const container = document . head || document . documentElement
29
- const scriptTag = document . createElement ( 'script' )
30
- scriptTag . setAttribute ( 'async' , 'false' )
31
- if ( content ) scriptTag . textContent = content
32
- else scriptTag . src = browser . runtime . getURL ( 'inpage.js' )
33
- container . insertBefore ( scriptTag , container . children [ 0 ] )
34
- container . removeChild ( scriptTag )
35
- INPAGE_INJECTED = true
36
- registerSite ( )
37
- } catch ( error ) {
38
- console . error ( 'Fluent Wallet: Provider injection failed.' , error )
39
- }
40
- }
41
-
42
24
let CONNECT_RETRY_COUNT = 0
43
25
let s
44
26
@@ -91,6 +73,10 @@ function setup() {
91
73
typeof e . data . msg !== 'object'
92
74
)
93
75
return
76
+ if ( e . data . msg . event === '__INPAGE_INJECTED__' ) {
77
+ registerSite ( )
78
+ return
79
+ }
94
80
if ( ! e . data . msg . method ) return
95
81
if ( e . data . msg . jsonrpc !== '2.0' ) return
96
82
if ( ! Number . isInteger ( e . data . msg . id ) ) return
@@ -125,7 +111,6 @@ function setup() {
125
111
)
126
112
} )
127
113
128
- if ( INPAGE_INJECTED ) registerSite ( )
114
+ registerSite ( )
129
115
}
130
- injectInpage ( )
131
116
setup ( )
0 commit comments