-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
35 lines (31 loc) · 914 Bytes
/
background.js
File metadata and controls
35 lines (31 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const changeUrl = (url) => {
const sites = [
"https://etherscan.io/",
"https://sepolia.etherscan.io/",
"https://holesky.etherscan.io/",
"https://optimistic.etherscan.io/",
"https://basescan.org/",
"https://sepolia.basescan.org/",
"https://polygonscan.com/",
"https://mumbai.polygonscan.com/",
"https://arbiscan.io/",
"https://bscscan.com/",
"https://blastscan.io/"
];
const regex = /\/(address|token)\/(0x[a-fA-F0-9]{40})/;
let newUrl = url;
if (regex.test(url)) {
const match = url.match(regex);
const address = match[2];
for (let i = 0; i < sites.length; i++) {
if (url.startsWith(sites[i])) {
newUrl = `${sites[(i + 1) % sites.length]}address/${address}`;
break;
}
}
}
return newUrl;
}
chrome.action.onClicked.addListener(function(tab) {
chrome.tabs.update(tab.id, {url: changeUrl(tab.url)});
});