diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d81cb8..fd9a74e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### v5.0.4 + +- [feat] Enhance the address label functionality on the Solscan token page + ### v5.0.3 - [fix] Restore the copy functionality for transaction hashes diff --git a/README.md b/README.md index af4132a..e1da200 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ For up to the minute news, follow our [Twitter](https://twitter.com/MetaDockTeam - [x] Show evm.storage shortcut - [x] Show transaction simulator - [x] Show Variable Logs +- [x] Manage Local Private Labels ## Supported Websites List @@ -65,6 +66,12 @@ For up to the minute news, follow our [Twitter](https://twitter.com/MetaDockTeam - tronscan.org - era.zksync.network - blockscout.com +- debank.com +- platform.arkhamintelligence.com +- scan.merlinchain.io +- solscan.io +- solana.fm +- explorer.solana.com ## Contributing diff --git a/package.json b/package.json index 2a8bac1..b0d19d7 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "metasuites", - "version": "5.0.3", + "version": "5.0.4", "repository": { "type": "git", "url": "https://github.com/blocksecteam/metasuites.git" }, "engines": { - "node": "18.17.0" + "node": "18.18.0" }, "type": "module", "scripts": { diff --git a/src/background/index.ts b/src/background/index.ts index 9092e0b..23e4877 100644 --- a/src/background/index.ts +++ b/src/background/index.ts @@ -166,7 +166,11 @@ browser.webRequest.onCompleted.addListener( 'https://api.solscan.io/v2/account/transaction?*', 'https://api.solscan.io/v2/account/v2/tokenaccounts?*', 'https://api.solscan.io/v2/account/stake?*', - 'https://api-v2.solscan.io/v2/account/activity/dextrading?*' + 'https://api-v2.solscan.io/v2/account/activity/dextrading?*', + 'https://api-v2.solscan.io/v2/token/transfer?address=*', + 'https://api.solscan.io/v2/account/transaction?address=*', + 'https://api.solscan.io/v2/token/holders?token=*', + 'https://api-v2.solscan.io/v2/token/activity/dextrading/total?address=*' ] } ) diff --git a/src/common/constants/scan.ts b/src/common/constants/scan.ts index e2cef24..fc4ba21 100644 --- a/src/common/constants/scan.ts +++ b/src/common/constants/scan.ts @@ -24,7 +24,7 @@ export const TRONSCAN_PAGE_NAMES = [ export const BLOCKSCOUT_PAGE_NAMES = ['TX', 'ADDRESS'] as const export const MERLINSCAN_PAGE_NAMES = ['TX'] as const -export const SOLSCAN_PAGE_NAMES = ['ACCOUNT', 'TX'] as const +export const SOLSCAN_PAGE_NAMES = ['ACCOUNT', 'TX', 'TOKEN'] as const export const SOLANAFM_PAGE_NAMES = ['ADDRESS', 'TX'] as const export const SOLANAEXPL_PAGE_NAMES = ['ADDRESS', 'TX'] as const export const ARKHAM_PAGE_NAMES = ['ADDRESS', 'TX'] as const @@ -171,6 +171,10 @@ export const SOLSCAN_PAGES: Record< name: 'ACCOUNT', pattern: /^\/account\/([1-9A-HJ-NP-Za-km-z]{32,44})/i }, + TOKEN: { + name: 'TOKEN', + pattern: /^\/token\/([1-9A-HJ-NP-Za-km-z]{32,44})/i + }, TX: { name: 'TX', pattern: /^\/tx\/([1-9A-Za-z]+)/i diff --git a/src/common/utils/validator.ts b/src/common/utils/validator.ts index 222c6f9..a4b57f1 100644 --- a/src/common/utils/validator.ts +++ b/src/common/utils/validator.ts @@ -7,7 +7,8 @@ import { PATTERN_SELECTOR_LOOSE, PATTERN_TRX_ADDRESS_LOOSE, PATTERN_TRX_ADDRESS_EXAC, - PATTERN_SOLANA_ADDRESS_EXAC + PATTERN_SOLANA_ADDRESS_EXAC, + PATTERN_SOLANA_ADDRESS_LOOSE } from '@common/constants' export const isAddress = (str: string): boolean => { @@ -37,6 +38,7 @@ export const pickAddress = (str: string): string | undefined => { return ( str.match(PATTERN_EVM_ADDRESS_LOOSE)?.[0] || str.match(PATTERN_BTC_ADDRESS_LOOSE)?.[0] || - str.match(PATTERN_TRX_ADDRESS_LOOSE)?.[0] + str.match(PATTERN_TRX_ADDRESS_LOOSE)?.[0] || + str.match(PATTERN_SOLANA_ADDRESS_LOOSE)?.[0] ) } diff --git a/src/content/etherscan/feat-scripts/main-address-label.tsx b/src/content/etherscan/feat-scripts/main-address-label.tsx index aea8028..fc23b09 100644 --- a/src/content/etherscan/feat-scripts/main-address-label.tsx +++ b/src/content/etherscan/feat-scripts/main-address-label.tsx @@ -23,10 +23,14 @@ const genMainAddressLabel = async (chain: string) => { await chromeEvent .emit(GET_IMPL_LABELS, { chain: chain, addresses: [mainAddress] }) .then((res: CallbackResponse | undefined) => { - const containerEl = $( - '#ContentPlaceHolder1_divSummary > div:first-child > div:first-child' + const divSummaryEl = $('#ContentPlaceHolder1_divSummary') + const containerEl = divSummaryEl.find( + '> div:first-child > div:first-child' ) - $('#ContentPlaceHolder1_divSummary > div').removeAttr('style') + divSummaryEl.find('> div').removeAttr('style') + if (!divSummaryEl.hasClass('pt-2')) { + divSummaryEl.addClass('pt-2') + } if (res?.success && res.data.length) { const label = res.data[0].label if ( diff --git a/src/content/solscan/feat-scripts/fund-flow.tsx b/src/content/solscan/feat-scripts/fund-flow.tsx index a1d8792..c32dd77 100644 --- a/src/content/solscan/feat-scripts/fund-flow.tsx +++ b/src/content/solscan/feat-scripts/fund-flow.tsx @@ -1,6 +1,8 @@ import { createRoot } from 'react-dom/client' import $ from 'jquery' +import { pickAddress } from '@common/utils' + import { FundFlowButton } from '../components' const renderFundFlowButton = async () => { @@ -8,11 +10,11 @@ const renderFundFlowButton = async () => { const mainAddressEl = $( '#__next > div:nth-of-type(1) > div:nth-of-type(3) > div:first-child > div:first-child > div:last-child > div:first-child > div:first-child > div' ) - if (mainAddressEl[0]) { - const mainAddress = mainAddressEl[0].innerText.trim() + const mainAddress = pickAddress(window.location.pathname) + if (mainAddress) { const btnRootEl = $('
') btnRootEl.css({ display: 'inline-block', verticalAlign: 'middle' }) - mainAddressEl?.append(btnRootEl) + mainAddressEl.append(btnRootEl) createRoot(btnRootEl[0]).render( ) diff --git a/src/content/solscan/main.tsx b/src/content/solscan/main.tsx index 16f3e5a..5d78ffe 100644 --- a/src/content/solscan/main.tsx +++ b/src/content/solscan/main.tsx @@ -3,7 +3,11 @@ import { store } from '@src/store' import { isAllowed, getPageName } from '@common/utils' import { SOLSCAN_PAGES } from '@common/constants' -import { initAccountPageScript, initTxPageScript } from './page-scripts' +import { + initAccountPageScript, + initTxPageScript, + initTokenPageScript +} from './page-scripts' const execute = async () => { const supportWebList = await store.get('supportWebList') @@ -18,6 +22,9 @@ const execute = async () => { case SOLSCAN_PAGES.ACCOUNT.name: initAccountPageScript() break + case SOLSCAN_PAGES.TOKEN.name: + initTokenPageScript() + break case SOLSCAN_PAGES.TX.name: initTxPageScript() break diff --git a/src/content/solscan/page-scripts/index.ts b/src/content/solscan/page-scripts/index.ts index 7d5d605..30d8686 100644 --- a/src/content/solscan/page-scripts/index.ts +++ b/src/content/solscan/page-scripts/index.ts @@ -1,2 +1,3 @@ export { default as initAccountPageScript } from './account' export { default as initTxPageScript } from './tx' +export { default as initTokenPageScript } from './token' diff --git a/src/content/solscan/page-scripts/token.tsx b/src/content/solscan/page-scripts/token.tsx new file mode 100644 index 0000000..0c3af9e --- /dev/null +++ b/src/content/solscan/page-scripts/token.tsx @@ -0,0 +1,29 @@ +import browser from 'webextension-polyfill' + +import { store } from '@src/store' +import { GET_SOLSCAN_ACCOUNT_TAB_DATA } from '@common/constants' + +import { renderFundFlowButton, renderEnhancedLabels } from '../feat-scripts' +import { lazyLoad } from '../helper' + +const initTokenPageScript = async () => { + const { fundFlow, enhancedLabels } = await store.get('options') + + lazyLoad(() => { + if (fundFlow) renderFundFlowButton() + if (enhancedLabels) { + renderEnhancedLabels() + } + }, 'div[data-state="active"] table tbody tr:not(:has(div.animate-pulse))') + + browser.runtime.onMessage.addListener((message, _sender, sendResponse) => { + if (message === GET_SOLSCAN_ACCOUNT_TAB_DATA) { + requestIdleCallback(() => { + if (enhancedLabels) renderEnhancedLabels() + }) + sendResponse() + } + }) +} + +export default initTokenPageScript