@onekeyfe/inpage-providers-hub 1.1.59 → 1.1.60

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,51 @@
1
+ # ONEKEY STANDARD SOURCE LICENSE (O-SSL)
2
+
3
+ This license governs use of the accompanying software. If you use the software,
4
+ you accept this license. If you do not accept the license, do not use the
5
+ software.
6
+
7
+ ## 1. Definitions
8
+
9
+ The terms "reproduce," "reproduction" and "distribution" have the same meaning
10
+ here as under Hong Kong copyright law.
11
+
12
+ "You" means the licensee of the software.
13
+
14
+ "Your company" means the company you worked for when you downloaded the
15
+ software.
16
+
17
+ "Reference use" means use of the software within your company as a reference,
18
+ in read only form, for the sole purposes of debugging your products,
19
+ maintaining your products, or enhancing the interoperability of your products
20
+ with the software, and specifically excludes the right to distribute the
21
+ software outside of your company.
22
+
23
+ "Licensed patents" means any Licensor patent claims which read directly on the
24
+ software as distributed by the Licensor under this license.
25
+
26
+ ## 2. Grant of Rights
27
+
28
+ (A) Copyright Grant - Subject to the terms of this license, the Licensor grants
29
+ you a non-transferable, non-exclusive, worldwide, royalty-free copyright
30
+ license to reproduce the software for reference use.
31
+
32
+ (B) Patent Grant - Subject to the terms of this license, the Licensor grants
33
+ you a non-transferable, non-exclusive, worldwide, royalty-free patent license
34
+ under licensed patents for reference use.
35
+
36
+ ## 3. Limitations
37
+
38
+ (A) No Trademark License - This license does not grant you any rights to use
39
+ the Licensor's name, logo, or trademarks.
40
+
41
+ (B) If you begin patent litigation against the Licensor over patents that you
42
+ think may apply to the software (including a cross-claim or counterclaim in
43
+ a lawsuit), your license to the software ends automatically.
44
+
45
+ (C) The software is licensed "as-is." You bear the risk of using it. The
46
+ Licensor gives no express warranties, guarantees or conditions. You may have
47
+ additional consumer rights under your local laws which this license cannot
48
+ change. To the extent permitted under your local laws, the Licensor excludes
49
+ the implied warranties of merchantability, fitness for a particular purpose and
50
+ non-infringement.This license agreement is governed by the laws of Hong Kong,
51
+ and any disputes related to this license agreement shall be resolved in accordance with Hong Kong law.
@@ -19,7 +19,6 @@ require("./sites/yearn");
19
19
  require("./sites/zapper");
20
20
  require("./sites/zerion");
21
21
  require("./sites/aave");
22
- require("./sites/pancake");
23
22
  require("./sites/unisat");
24
23
  require("./sites/gamma");
25
24
  require("./sites/idclub");
@@ -63,6 +63,11 @@ exports.basicWalletInfo = {
63
63
  updatedName: consts_1.WALLET_CONNECT_INFO.martian.text,
64
64
  name: /^Martian$/i,
65
65
  },
66
+ [consts_1.WALLET_NAMES.nami]: {
67
+ updatedIcon: consts_1.WALLET_CONNECT_INFO.nami.icon,
68
+ updatedName: consts_1.WALLET_CONNECT_INFO.nami.text,
69
+ name: /^(Nami Wallet|Nami)$/i,
70
+ },
66
71
  };
67
72
  exports.sitesConfig = [
68
73
  {
@@ -324,6 +329,7 @@ exports.sitesConfig = [
324
329
  },
325
330
  {
326
331
  urls: ['merlinchain.io'],
332
+ skip: { mobile: true },
327
333
  walletsForProvider: {
328
334
  [cross_inpage_provider_types_1.IInjectedProviderNames.btc]: [
329
335
  Object.assign(Object.assign({}, exports.basicWalletInfo['unisat']), { container: () => {
@@ -331,14 +337,22 @@ exports.sitesConfig = [
331
337
  return (window.getComputedStyle(e).pointerEvents != 'none' &&
332
338
  e.innerText.includes('BTC wallets'));
333
339
  });
340
+ }, afterUpdate(textNode, img) {
341
+ textNode.parentElement && (0, textUtils_1.makeTextEllipse)(textNode.parentElement);
334
342
  } }),
335
343
  ],
336
344
  },
337
345
  },
346
+ // todo:speed
338
347
  {
339
348
  urls: ['app.justlend.org'],
349
+ mutationObserverOptions: {
350
+ childList: true,
351
+ subtree: true,
352
+ attributes: true,
353
+ },
340
354
  walletsForProvider: {
341
- [cross_inpage_provider_types_1.IInjectedProviderNames.btc]: [
355
+ [cross_inpage_provider_types_1.IInjectedProviderNames.tron]: [
342
356
  Object.assign(Object.assign({}, exports.basicWalletInfo['tronlink']), { container: () => {
343
357
  return (0, utils_1.getConnectWalletModalByTitle)('div.connect-modal-v2.entry-modal-v2', 'Connect Wallet');
344
358
  } }),
@@ -351,7 +365,7 @@ exports.sitesConfig = [
351
365
  mobile: true, //WARN: it seems not supported by the site
352
366
  },
353
367
  walletsForProvider: {
354
- [cross_inpage_provider_types_1.IInjectedProviderNames.btc]: [
368
+ [cross_inpage_provider_types_1.IInjectedProviderNames.tron]: [
355
369
  Object.assign(Object.assign({}, exports.basicWalletInfo['tronlink']), { container: () => {
356
370
  return (0, utils_1.getConnectWalletModalByTitle)('div.wallet-modal', 'Connect Wallet');
357
371
  } }),
@@ -1132,16 +1146,6 @@ exports.sitesConfig = [
1132
1146
  ],
1133
1147
  },
1134
1148
  },
1135
- {
1136
- urls: ['app.hubbleprotocol.io'],
1137
- walletsForProvider: {
1138
- [cross_inpage_provider_types_1.IInjectedProviderNames.solana]: [
1139
- Object.assign(Object.assign({}, exports.basicWalletInfo['phantom']), { container() {
1140
- return (0, utils_1.getConnectWalletModalByTitle)('div.ant-modal-content', 'Select your wallet');
1141
- } }),
1142
- ],
1143
- },
1144
- },
1145
1149
  {
1146
1150
  urls: ['app.wagmi.com'],
1147
1151
  constraintMap: { icon: [imgUtils_1.isWalletIconSizeMatch], text: [] },
@@ -1186,7 +1190,7 @@ exports.sitesConfig = [
1186
1190
  {
1187
1191
  urls: ['www.theidols.io'],
1188
1192
  skip: {
1189
- mobile: true, //没弹窗
1193
+ mobile: true, //没弹窗
1190
1194
  },
1191
1195
  testUrls: ['www.theidols.io/marketplace'],
1192
1196
  walletsForProvider: {
@@ -1198,7 +1202,7 @@ exports.sitesConfig = [
1198
1202
  {
1199
1203
  urls: ['netswap.io'],
1200
1204
  skip: {
1201
- mobile: true, //没弹窗
1205
+ mobile: true, //没弹窗
1202
1206
  },
1203
1207
  walletsForProvider: {
1204
1208
  [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum]: [
@@ -1210,7 +1214,7 @@ exports.sitesConfig = [
1210
1214
  urls: ['rosswap.com'],
1211
1215
  constraintMap: { icon: [imgUtils_1.isWalletIconSizeMatch], text: [] },
1212
1216
  skip: {
1213
- mobile: true, //没弹窗
1217
+ mobile: true, //没弹窗
1214
1218
  },
1215
1219
  // skip:
1216
1220
  walletsForProvider: {
@@ -1223,7 +1227,7 @@ exports.sitesConfig = [
1223
1227
  urls: ['maiadao.io'],
1224
1228
  constraintMap: { icon: [imgUtils_1.isWalletIconSizeMatch], text: [] },
1225
1229
  skip: {
1226
- mobile: true, //没弹窗
1230
+ mobile: true, //没弹窗
1227
1231
  },
1228
1232
  walletsForProvider: {
1229
1233
  [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum]: [
@@ -1254,59 +1258,243 @@ exports.sitesConfig = [
1254
1258
  ],
1255
1259
  },
1256
1260
  },
1261
+ {
1262
+ urls: ['www.staderlabs.com'],
1263
+ skip: {
1264
+ mobile: true, //tmp skip for lack walletconnet
1265
+ },
1266
+ testUrls: ['www.staderlabs.com/eth/stake/'],
1267
+ constraintMap: { icon: [imgUtils_1.isWalletIconSizeMatch], text: [] },
1268
+ walletsForProvider: {
1269
+ [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum]: [
1270
+ Object.assign(Object.assign({}, exports.basicWalletInfo['metamask']), { findIconAndName({ name }) {
1271
+ const modal = (0, utils_1.getConnectWalletModalByTitle)('.chakra-modal__content-container', 'Select wallet') ||
1272
+ (0, utils_1.getConnectWalletModalByTitle)('#__CONNECTKIT__', 'Connect Wallet');
1273
+ if (!modal) {
1274
+ return null;
1275
+ }
1276
+ return ((0, findIconAndName_1.findIconAndNameByParent)(modal, name, {
1277
+ text: [],
1278
+ icon: [],
1279
+ }) ||
1280
+ (0, findIconAndName_1.findIconAndNameDirectly)('img[src*="media/mm"][alt="metaMask Logo"]', 'auto-search-text', name, modal, { text: [], icon: [] }, 5));
1281
+ },
1282
+ afterUpdate(text, icon) {
1283
+ var _a;
1284
+ const parent = (_a = text.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
1285
+ const imgContainer = parent === null || parent === void 0 ? void 0 : parent.firstChild;
1286
+ if (parent && imgContainer) {
1287
+ imgContainer.style.display = 'flex';
1288
+ imgContainer.style.alignItems = 'center';
1289
+ imgContainer.style.borderRadius = '0';
1290
+ imgContainer.style.flexShrink = '0';
1291
+ }
1292
+ } }),
1293
+ Object.assign(Object.assign({}, exports.basicWalletInfo['walletconnect']), { findIconAndName({ name }) {
1294
+ const modal = (0, utils_1.getConnectWalletModalByTitle)('.chakra-modal__content-container', 'Select wallet') ||
1295
+ (0, utils_1.getConnectWalletModalByTitle)('#__CONNECTKIT__', 'Connect Wallet');
1296
+ if (!modal) {
1297
+ return null;
1298
+ }
1299
+ return (0, findIconAndName_1.findIconAndNameDirectly)('img[alt="walletConnect Logo"]', 'auto-search-text', name, modal, { text: [], icon: [] }, 5);
1300
+ },
1301
+ afterUpdate(text, icon) {
1302
+ var _a;
1303
+ const parent = (_a = text.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
1304
+ const imgContainer = parent === null || parent === void 0 ? void 0 : parent.firstChild;
1305
+ if (parent && imgContainer) {
1306
+ imgContainer.style.display = 'flex';
1307
+ imgContainer.style.alignItems = 'center';
1308
+ imgContainer.style.borderRadius = '0';
1309
+ imgContainer.style.flexShrink = '0';
1310
+ }
1311
+ } }),
1312
+ ],
1313
+ },
1314
+ },
1315
+ {
1316
+ urls: ['stake.solblaze.org'],
1317
+ testPath: [':text("Agree")', ':text("Connect Wallet")'],
1318
+ testUrls: ['stake.solblaze.org/app'],
1319
+ walletsForProvider: {
1320
+ [cross_inpage_provider_types_1.IInjectedProviderNames.solana]: [
1321
+ Object.assign(Object.assign({}, exports.basicWalletInfo['phantom']), { container: '#connect_modal', afterUpdate(text, icon) {
1322
+ var _a;
1323
+ if ((_a = text.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement) {
1324
+ text.parentElement.parentElement.style.whiteSpace = 'noWrap';
1325
+ (0, textUtils_1.makeTextEllipse)(text.parentElement, 'min(18vw,107px)');
1326
+ }
1327
+ } }),
1328
+ ],
1329
+ },
1330
+ },
1331
+ {
1332
+ urls: ['buzz.bsquared.network'],
1333
+ skip: true,
1334
+ walletsForProvider: {
1335
+ [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum]: [
1336
+ Object.assign(Object.assign({}, exports.basicWalletInfo['metamask']), { container: () => (0, utils_1.getConnectWalletModalByTitle)('.modalContent', 'Connect Wallet') }),
1337
+ ],
1338
+ [cross_inpage_provider_types_1.IInjectedProviderNames.btc]: [
1339
+ Object.assign(Object.assign({}, exports.basicWalletInfo['unisat']), { findIconAndName({ name }) {
1340
+ const modal = (0, utils_1.getConnectWalletModalByTitle)('.modalContent', 'Connect Wallet');
1341
+ return (modal &&
1342
+ (0, findIconAndName_1.findIconAndNameDirectly)('img[src*="layout/unisat.png"]', 'auto-search-text', name));
1343
+ } }),
1344
+ ],
1345
+ },
1346
+ },
1347
+ {
1348
+ urls: ['task.bsquared.network'],
1349
+ skip: { mobile: true },
1350
+ walletsForProvider: {
1351
+ [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum]: [
1352
+ Object.assign(Object.assign({}, exports.basicWalletInfo['metamask']), { container: () => (0, utils_1.getConnectWalletModalByTitle)('.ReactModal__Content', 'Please Connect A Wallet') }),
1353
+ ],
1354
+ [cross_inpage_provider_types_1.IInjectedProviderNames.btc]: [
1355
+ Object.assign(Object.assign({}, exports.basicWalletInfo['unisat']), { container: () => (0, utils_1.getConnectWalletModalByTitle)('.ReactModal__Content', 'Please Connect A Wallet') }),
1356
+ ],
1357
+ },
1358
+ },
1359
+ {
1360
+ urls: ['juststable.tronscan.org'],
1361
+ testPath: [':text("Enter")'],
1362
+ skip: true,
1363
+ walletsForProvider: {
1364
+ [cross_inpage_provider_types_1.IInjectedProviderNames.tron]: [
1365
+ Object.assign(Object.assign({}, exports.basicWalletInfo['tronlink']), { update({ name, updatedName, updatedIcon }) {
1366
+ const button = document.querySelector('button.ant-btn.tronlinkLogin');
1367
+ const text = button && (0, textUtils_1.findWalletTextByParent)(button, name, []);
1368
+ text && (0, textUtils_1.replaceText)(text, updatedName);
1369
+ button && (button.style.backgroundImage = `url(${updatedIcon})`);
1370
+ return null;
1371
+ } }),
1372
+ ],
1373
+ },
1374
+ },
1375
+ {
1376
+ urls: ['app.cetus.zone'],
1377
+ testPath: ['div.radio', 'button:has-text("Continue")', 'button:has-text("Connect Wallet")'],
1378
+ walletsForProvider: {
1379
+ [cross_inpage_provider_types_1.IInjectedProviderNames.aptos]: [
1380
+ Object.assign(Object.assign({}, exports.basicWalletInfo['martian']), { container: 'div.ant-modal.wallet-modal' }),
1381
+ //petra不存在
1382
+ // {
1383
+ // ...basicWalletInfo['petra'],
1384
+ // container: 'div.ant-modal.wallet-modal',
1385
+ // },
1386
+ ],
1387
+ [cross_inpage_provider_types_1.IInjectedProviderNames.sui]: [
1388
+ Object.assign(Object.assign({}, exports.basicWalletInfo['suiwallet']), { name: /^Sui Wallet$/i, container: 'div.ant-modal.wallet-modal' }),
1389
+ ],
1390
+ },
1391
+ },
1392
+ //全是shadow dom
1257
1393
  // {
1258
- // urls: ['www.staderlabs.com'],
1259
- // only: true,
1260
- // testUrls: ['www.staderlabs.com/eth/stake/'],
1261
- // constraintMap: { icon: [isWalletIconSizeMatch], text: [] },
1394
+ // urls: ['www.pinksale.finance'],
1262
1395
  // walletsForProvider: {
1263
1396
  // [IInjectedProviderNames.ethereum]: [
1264
1397
  // {
1265
1398
  // ...basicWalletInfo['metamask'],
1266
- // findIconAndName({ name }) {
1267
- // const modal = getConnectWalletModalByTitle('.chakra-modal__content-container', 'Select wallet')
1268
- // return (
1269
- // modal &&
1270
- // findIconAndNameDirectly(
1271
- // 'img[src*="media/mm"][alt="metaMask Logo"]',
1272
- // 'auto-search-text',
1273
- // name,
1274
- // modal,
1275
- // { text: [], icon: [] },
1276
- // 6
1277
- // )
1278
- // );
1279
- // },
1280
- // afterUpdate(text, icon) {
1281
- // icon.style.minHeight = '40px'
1282
- // icon.style.height = '40px'
1283
- // icon.style.width = '40px'
1284
- // icon.style.minWidth = '40px'
1285
- // }
1286
1399
  // },
1287
1400
  // {
1288
1401
  // ...basicWalletInfo['walletconnect'],
1289
- // findIconAndName({ name }) {
1290
- // const modal = getConnectWalletModalByTitle('.chakra-modal__content-container', 'Select wallet')
1291
- // return (
1292
- // modal &&
1293
- // findIconAndNameDirectly(
1294
- // 'img[src*="media/wc"][alt="walletConnect Logo"]',
1295
- // 'auto-search-text',
1296
- // name,
1297
- // modal, { text: [], icon: [] },
1298
- // 6
1299
- // )
1300
- // );
1301
- // },
1302
- // afterUpdate(text, icon) {
1303
- // icon.style.minHeight = '40px'
1304
- // icon.style.height = '40px'
1305
- // icon.style.width = '40px'
1306
- // icon.style.minWidth = '40px'
1307
- // }
1308
1402
  // },
1309
1403
  // ],
1310
1404
  // },
1311
1405
  // },
1406
+ {
1407
+ urls: ['app.radiant.capital'],
1408
+ testPath: [':text("Continue")', ':text("Connect Wallet")'],
1409
+ walletsForProvider: {
1410
+ [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum]: [
1411
+ Object.assign(Object.assign({ container: '.connect-wallet-modal' }, exports.basicWalletInfo['walletconnect']), { afterUpdate(textNode, img) {
1412
+ img.style.height = '40px';
1413
+ img.style.width = '40px';
1414
+ } }),
1415
+ ],
1416
+ },
1417
+ },
1418
+ {
1419
+ urls: ['app.ariesmarkets.xyz'],
1420
+ testUrls: ['app.ariesmarkets.xyz/lending'],
1421
+ // mutationObserverOptions: {
1422
+ // childList: true,
1423
+ // subtree: true,
1424
+ // attributes: true,
1425
+ // },
1426
+ //TODO: mobile version
1427
+ constraintMap: { icon: [imgUtils_1.isWalletIconSizeMatch], text: [] },
1428
+ walletsForProvider: {
1429
+ [cross_inpage_provider_types_1.IInjectedProviderNames.aptos]: [
1430
+ Object.assign(Object.assign({}, exports.basicWalletInfo['petra']), { container: () => {
1431
+ var _a, _b, _c;
1432
+ const pc = (0, utils_1.getConnectWalletModalByTitle)('div.mantine-Paper-root', 'Select Wallet');
1433
+ const mobileTitle = utilsDomNodes_1.default.findTextNode('#root', 'Select Wallet', 'first') || null;
1434
+ return (pc || ((_c = (_b = (_a = mobileTitle === null || mobileTitle === void 0 ? void 0 : mobileTitle.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.parentElement) === null || _c === void 0 ? void 0 : _c.parentElement) || null);
1435
+ } }),
1436
+ ],
1437
+ },
1438
+ },
1439
+ {
1440
+ urls: ['app.indigoprotocol.io'],
1441
+ // testPath: [':text("I agree")', ':text("Connect")'],
1442
+ constraintMap: { icon: [], text: [] },
1443
+ walletsForProvider: {
1444
+ [cross_inpage_provider_types_1.IInjectedProviderNames.cardano]: [
1445
+ Object.assign(Object.assign({}, exports.basicWalletInfo['nami']), { container: () => {
1446
+ return (0, utils_1.getConnectWalletModalByTitle)('#modal-connect-wallet', 'Connect Wallet');
1447
+ } }),
1448
+ ],
1449
+ },
1450
+ },
1451
+ {
1452
+ urls: ['app.minswap.org'],
1453
+ testPath: {
1454
+ desktop: [':text("Connect Wallet")'],
1455
+ mobile: ['header.flex > button>svg', ':text("Connect Wallet")'],
1456
+ },
1457
+ skip: true,
1458
+ walletsForProvider: {
1459
+ [cross_inpage_provider_types_1.IInjectedProviderNames.cardano]: [
1460
+ Object.assign(Object.assign({}, exports.basicWalletInfo['nami']), { findIconAndName({ name }) {
1461
+ const modal = (0, utils_1.getConnectWalletModalByTitle)('div.dialog-connect-wallet', 'Connect wallet');
1462
+ return (modal &&
1463
+ (0, findIconAndName_1.findIconAndNameDirectly)('img[src*="nami.svg"][alt="Nami"]', 'auto-search-text', name, modal, { text: [], icon: [] }, 6));
1464
+ } }),
1465
+ ],
1466
+ },
1467
+ },
1468
+ {
1469
+ urls: ['pancakeswap.finance', 'app.pancakeswap.finance', 'www.pancakeswap.finance'],
1470
+ skip: {
1471
+ mobile: true, //temp skip for lack walletconnect
1472
+ },
1473
+ walletsForProvider: {
1474
+ [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum]: [
1475
+ Object.assign(Object.assign({}, exports.basicWalletInfo['metamask']), { findIconAndName({ name }) {
1476
+ const modal = (0, utils_1.getConnectWalletModalByTitle)('#portal-root', 'Connect Wallet');
1477
+ return (modal &&
1478
+ (0, findIconAndName_1.findIconAndNameDirectly)('img[src*="wallets/metamask.png"]', 'auto-search-text', name, modal, { text: [], icon: [] }, 5));
1479
+ } }),
1480
+ Object.assign(Object.assign({}, exports.basicWalletInfo['walletconnect']), { findIconAndName({ name }) {
1481
+ const modal = (0, utils_1.getConnectWalletModalByTitle)('#portal-root', 'Connect Wallet');
1482
+ return (modal &&
1483
+ (0, findIconAndName_1.findIconAndNameDirectly)('img[src*="wallets/walletconnect.png"]', 'auto-search-text', name, modal, { text: [], icon: [] }, 5));
1484
+ } }),
1485
+ ],
1486
+ },
1487
+ },
1488
+ {
1489
+ urls: ['www.nucleon.space'],
1490
+ testUrls: ['www.nucleon.space/#/data/stake'],
1491
+ walletsForProvider: {
1492
+ [cross_inpage_provider_types_1.IInjectedProviderNames.ethereum]: [
1493
+ Object.assign(Object.assign({}, exports.basicWalletInfo['metamask']), { container: () => (0, utils_1.getConnectWalletModalByTitle)('div.ant-modal-content', 'Select a Wallet'), afterUpdate(textNode, icon) {
1494
+ icon.style.height = '28px';
1495
+ icon.style.width = 'auto';
1496
+ } }),
1497
+ ],
1498
+ },
1499
+ },
1312
1500
  ];
@@ -29,6 +29,7 @@ function findIconAndNameByParent(containerElement, walletName, constraints = {
29
29
  let level = 0;
30
30
  while (parent && parent !== (containerElement === null || containerElement === void 0 ? void 0 : containerElement.parentElement) && level++ < consts_1.MAX_LEVELS) {
31
31
  const walletIcon = (0, imgUtils_1.findWalletIconByParent)(parent, constraints.icon);
32
+ //TODO: unnecessary to traverse the parent node if the icon have more than one
32
33
  if (!walletIcon) {
33
34
  parent = parent.parentElement;
34
35
  continue;
@@ -49,9 +50,8 @@ function findIconAndNameDirectly(iconSelector, textSelector, name, container = d
49
50
  const iconElements = typeof iconSelector === 'string'
50
51
  ? container.querySelectorAll(iconSelector)
51
52
  : (0, utils_1.arrayify)(iconSelector());
52
- utils_1.universalLog.log('iconElements', iconElements);
53
53
  if (iconElements.length > 1) {
54
- utils_1.universalLog.error('more one wallet icon found ,please check the selector');
54
+ utils_1.universalLog.warn('more one wallet icon found ,please check the selector');
55
55
  return null;
56
56
  }
57
57
  const iconElement = Array.from(iconElements)[0];
@@ -65,7 +65,7 @@ function findIconAndNameDirectly(iconSelector, textSelector, name, container = d
65
65
  else if (typeof textSelector === 'string') {
66
66
  const textContainer = (_a = Array.from(container.querySelectorAll(textSelector))) === null || _a === void 0 ? void 0 : _a.filter(Boolean);
67
67
  if ((textContainer === null || textContainer === void 0 ? void 0 : textContainer.length) > 1) {
68
- utils_1.universalLog.error('more one wallet text found ,please check the selector');
68
+ utils_1.universalLog.warn('more one wallet text found ,please check the selector');
69
69
  return null;
70
70
  }
71
71
  textNode = (0, textUtils_1.findWalletTextByParent)(textContainer[0], name, constraints.text);
@@ -78,7 +78,7 @@ function findIconAndNameDirectly(iconSelector, textSelector, name, container = d
78
78
  : null;
79
79
  }
80
80
  else {
81
- utils_1.universalLog.error('textSelector is wrong');
81
+ utils_1.universalLog.warn('textSelector is wrong');
82
82
  return null;
83
83
  }
84
84
  if (!iconElement || !textNode) {
@@ -102,7 +102,7 @@ function findTextByImg(img, walletName, containerLimit, constraints, maxLevel =
102
102
  }
103
103
  parent = parent.parentElement;
104
104
  }
105
- utils_1.universalLog.error('can not find the text node by img', level);
105
+ utils_1.universalLog.warn('can not find the text node by img', level);
106
106
  return null;
107
107
  }
108
108
  exports.findTextByImg = findTextByImg;
@@ -3,21 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isWalletIconSizeMatch = exports.findWalletIconByParent = exports.findIconNodesByParent = exports.createImageEle = exports.replaceIcon = void 0;
4
4
  const consts_1 = require("./consts");
5
5
  const utils_1 = require("./utils");
6
+ /**
7
+ * @note: lazy loading image with width and height 0
8
+ */
6
9
  function replaceIcon(originalNode, newIconSrc) {
7
10
  const computedstyle = window.getComputedStyle(originalNode);
8
- utils_1.universalLog.log('===>ok: replace icon');
11
+ utils_1.universalLog.log('===>ok: replace icon', originalNode);
12
+ const width = parseFloat(computedstyle.width) ? computedstyle.width : 'auto';
13
+ const height = parseFloat(computedstyle.height) ? computedstyle.height : 'auto';
9
14
  if (originalNode instanceof HTMLImageElement) {
10
15
  originalNode.src = newIconSrc;
11
16
  originalNode.removeAttribute('srcset');
12
- originalNode.style.width = computedstyle.width;
13
- originalNode.style.height = computedstyle.height;
17
+ originalNode.style.width = width;
18
+ originalNode.style.height = height;
14
19
  originalNode.classList.add(...Array.from(originalNode.classList));
15
20
  return originalNode;
16
21
  }
17
22
  else {
18
23
  const imgNode = createImageEle(newIconSrc);
19
- imgNode.style.width = computedstyle.width;
20
- imgNode.style.height = computedstyle.height;
24
+ imgNode.style.width = width;
25
+ imgNode.style.height = height;
21
26
  imgNode.classList.add(...Array.from(originalNode.classList));
22
27
  originalNode.replaceWith(imgNode);
23
28
  return imgNode;
@@ -54,25 +59,30 @@ exports.findIconNodesByParent = findIconNodesByParent;
54
59
  */
55
60
  function findWalletIconByParent(parent, constraints) {
56
61
  const iconNodes = findIconNodesByParent(parent);
62
+ if (iconNodes.length === 0) {
63
+ utils_1.universalLog.warn(`===>no icon node found`, parent);
64
+ return null;
65
+ }
57
66
  if (iconNodes.length > 1) {
58
67
  utils_1.universalLog.warn(`===>more than one icon node found`, iconNodes.length, iconNodes);
59
68
  return null;
60
69
  }
61
70
  const icon = iconNodes[0];
62
- if (!icon || constraints.some((f) => !f(icon))) {
63
- utils_1.universalLog.warn(`===>it doesnt satisfy the constraints`, icon);
71
+ if (constraints.some((f) => !f(icon))) {
72
+ utils_1.universalLog.warn('it doesnt satisfy the constraints');
64
73
  return null;
65
74
  }
66
75
  return icon;
67
76
  }
68
77
  exports.findWalletIconByParent = findWalletIconByParent;
78
+ //TODO: deal with lazy loading image
69
79
  function isWalletIconSizeMatch(walletIcon) {
70
80
  const { width, height } = walletIcon.getBoundingClientRect();
71
81
  const isMatch = width < consts_1.ICON_MAX_SIZE &&
72
82
  width > consts_1.ICON_MIN_SIZE &&
73
83
  height < consts_1.ICON_MAX_SIZE &&
74
84
  height > consts_1.ICON_MIN_SIZE;
75
- utils_1.universalLog.log('===>wallet icon size match: ', isMatch);
85
+ !isMatch && utils_1.universalLog.log('===>wallet icon size doesnot match: ', width, height);
76
86
  return isMatch;
77
87
  }
78
88
  exports.isWalletIconSizeMatch = isWalletIconSizeMatch;
@@ -59,11 +59,12 @@ function hackWalletConnectButton(sites) {
59
59
  const newText = updateName(textNode, updatedName);
60
60
  const newIconElement = updateIcon(iconNode, updatedIcon);
61
61
  walletId.updateFlag(newIconElement);
62
+ (0, textUtils_1.makeTextEllipse)(newText.parentElement);
62
63
  afterUpdate === null || afterUpdate === void 0 ? void 0 : afterUpdate(newText, newIconElement);
63
64
  }
64
65
  }
65
66
  catch (e) {
66
- utils_1.universalLog.error(e);
67
+ utils_1.universalLog.warn(e);
67
68
  }
68
69
  }
69
70
  }
@@ -76,5 +77,5 @@ try {
76
77
  hackWalletConnectButton(config_1.sitesConfig);
77
78
  }
78
79
  catch (e) {
79
- utils_1.universalLog.error(e);
80
+ utils_1.universalLog.warn(e);
80
81
  }
@@ -8,7 +8,7 @@ function findIconAndNameInShadowRoot(hostSelector, containerSelector, walletName
8
8
  .filter(Boolean)
9
9
  .map((e) => e.shadowRoot);
10
10
  if (shadowRoots.length === 0) {
11
- utils_1.universalLog.error('findIconAndNameInShadowRoot,shadowRoots.length=0');
11
+ utils_1.universalLog.warn('findIconAndNameInShadowRoot,shadowRoots.length=0');
12
12
  return null;
13
13
  }
14
14
  const containerElements = shadowRoots
@@ -17,7 +17,7 @@ function findIconAndNameInShadowRoot(hostSelector, containerSelector, walletName
17
17
  .filter(Boolean);
18
18
  const length = containerElements.length;
19
19
  if (length === 0 || length > 1) {
20
- utils_1.universalLog.error('findIconAndNameInShadowRoot,length=', length);
20
+ utils_1.universalLog.warn('findIconAndNameInShadowRoot,length=', length);
21
21
  return null;
22
22
  }
23
23
  return (0, findIconAndName_1.findIconAndNameByParent)(containerElements[0], walletName);
@@ -6,10 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.findWalletTextByParent = exports.replaceText = exports.makeTextEllipse = void 0;
7
7
  const utilsDomNodes_1 = __importDefault(require("../utils/utilsDomNodes"));
8
8
  const utils_1 = require("./utils");
9
- function makeTextEllipse(textNode) {
9
+ function makeTextEllipse(textNode, mWidth) {
10
10
  textNode.style.whiteSpace = 'nowrap';
11
11
  textNode.style.overflow = 'hidden';
12
12
  textNode.style.textOverflow = 'ellipsis';
13
+ mWidth && (textNode.style.maxWidth = mWidth);
13
14
  }
14
15
  exports.makeTextEllipse = makeTextEllipse;
15
16
  function replaceText(textNode, newText) {
@@ -24,15 +25,15 @@ exports.replaceText = replaceText;
24
25
  */
25
26
  function findWalletTextByParent(container, walletName, constraints) {
26
27
  if (!(container instanceof HTMLElement)) {
27
- utils_1.universalLog.warn('arg is wrong. container is not a HTMLElement');
28
+ utils_1.universalLog.warn('arg is wrong. container is not a HTMLElement', container);
28
29
  return null;
29
30
  }
30
31
  const textNodes = utilsDomNodes_1.default.findTextNode(container, walletName, 'all');
31
- if (!textNodes) {
32
+ const length = (textNodes === null || textNodes === void 0 ? void 0 : textNodes.length) || 0;
33
+ if (length === 0 || !textNodes) {
32
34
  utils_1.universalLog.warn(`===>find none for wallet name ${walletName.toString()}`);
33
35
  return null;
34
36
  }
35
- const length = (textNodes === null || textNodes === void 0 ? void 0 : textNodes.length) || 0;
36
37
  if (length > 1) {
37
38
  utils_1.universalLog.warn(`===>find more than one text node for wallet name ${walletName.toString()}`);
38
39
  return null;
@@ -15,7 +15,6 @@ import './sites/yearn';
15
15
  import './sites/zapper';
16
16
  import './sites/zerion';
17
17
  import './sites/aave';
18
- import './sites/pancake';
19
18
  import './sites/unisat';
20
19
  import './sites/gamma';
21
20
  import './sites/idclub';
@@ -17,7 +17,6 @@ import './sites/yearn';
17
17
  import './sites/zapper';
18
18
  import './sites/zerion';
19
19
  import './sites/aave';
20
- import './sites/pancake';
21
20
  import './sites/unisat';
22
21
  import './sites/gamma';
23
22
  import './sites/idclub';