1
1
/* eslint-disable no-console */
2
2
// import { onMessage, sendMessage } from "webext-bridge";
3
- // import browser from "webextension-polyfill";
3
+ import * as browser from "webextension-polyfill" ;
4
4
import Mark from "mark.js" ;
5
5
import "@webcomponents/webcomponentsjs/webcomponents-bundle.js" ;
6
6
import { coinGeko } from "./views/network" ;
@@ -11,6 +11,7 @@ import "./views/AddressHighlight.svelte";
11
11
import "./views/TrxHighlight.svelte" ;
12
12
import "./views/NativeTokenHighlight.svelte" ;
13
13
import { escapeRegex } from "./views/utils" ;
14
+ import { sendMessage } from "webext-bridge" ;
14
15
15
16
const regexETHTrx = / 0 x [ a - f A - F 0 - 9 ] { 64 } / g; // TODO: Ignore longer address
16
17
const regexETHAddress = / 0 x [ a - f A - F 0 - 9 ] { 40 } / g; // TODO: Solana, Near regex
@@ -90,19 +91,24 @@ const getCoinList = async () => {
90
91
91
92
// Firefox `browser.tabs.executeScript()` requires scripts return a primitive value
92
93
( async ( ) => {
93
- // const coinList: { [key: string]: string | number }[] =
94
- // (await sendMessage("coinList", { limit: 500 })) || [];
94
+ const coinList : { [ key : string ] : string | number } [ ] =
95
+ ( await sendMessage ( "coinList" , { limit : 500 } ) ) || [ ] ;
95
96
96
- const coinList = ( await getCoinList ( ) ) || [ ] ;
97
+ console . log ( coinList ) ;
98
+
99
+ // const coinList = (await getCoinList()) || [];
97
100
98
101
const nameAndSymbolList : string [ ] = [
99
102
...coinList . map ( ( item : any ) => item . symbol . toUpperCase ( ) ) ,
100
103
] ;
101
104
102
105
const regexNativeToken = new RegExp (
103
- `\\b(${ nameAndSymbolList . slice ( 0 , 500 ) . map ( function ( w ) {
104
- return escapeRegex ( w ) ;
105
- } ) . join ( "|" ) } )\\b`,
106
+ `\\b(${ nameAndSymbolList
107
+ . slice ( 0 , 500 )
108
+ . map ( function ( w ) {
109
+ return escapeRegex ( w ) ;
110
+ } )
111
+ . join ( "|" ) } )\\b`,
106
112
"g"
107
113
) ;
108
114
@@ -205,8 +211,6 @@ const getCoinList = async () => {
205
211
data . symbol === item . innerText || data . name === item . innerText
206
212
) ;
207
213
208
- console . log ( "selectedItem: " , selectedItem )
209
-
210
214
// Inject address as props
211
215
item . setAttribute ( "id" , selectedItem ?. id ) ;
212
216
item . setAttribute ( "name" , item . innerText ) ;
0 commit comments