Skip to content

Commit

Permalink
chore:improved iframe scan
Browse files Browse the repository at this point in the history
  • Loading branch information
xtools-at committed Nov 2, 2023
1 parent 91069ec commit 46a47b9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 49 deletions.
39 changes: 22 additions & 17 deletions config/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -1274,8 +1274,7 @@
{
"name": "alphscan",
"url": "https://explorer.alph.network",
"standard": "EIP3091",
"iframe": true
"standard": "EIP3091"
}
],
"shortName": "alph"
Expand Down Expand Up @@ -1543,7 +1542,8 @@
{
"name": "a8scan-testnet",
"url": "https://testnet.a8scan.io",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"shortName": "a8"
Expand Down Expand Up @@ -2547,8 +2547,7 @@
{
"name": "Bitrock Testnet Explorer",
"url": "https://testnetscan.bit-rock.io",
"standard": "EIP3091",
"iframe": true
"standard": "EIP3091"
}
],
"shortName": "tbitrock"
Expand Down Expand Up @@ -3519,8 +3518,7 @@
{
"name": "scoville-explorer",
"url": "https://scoville-explorer.chiliz.com",
"standard": "none",
"iframe": true
"standard": "none"
}
],
"shortName": "chz"
Expand Down Expand Up @@ -5067,8 +5065,7 @@
"name": "blockscout",
"url": "https://blockexplorer.electroneum.com",
"icon": "electroneum",
"standard": "EIP3091",
"iframe": true
"standard": "EIP3091"
}
],
"shortName": "etn-mainnet"
Expand Down Expand Up @@ -9805,7 +9802,8 @@
{
"name": "modescout",
"url": "https://sepolia.explorer.mode.network",
"standard": "none"
"standard": "none",
"iframe": true
}
],
"shortName": "modesep"
Expand Down Expand Up @@ -11266,7 +11264,8 @@
"name": "orderlyscout",
"url": "https://explorer.orderly.network",
"icon": "blockscout",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"shortName": "orderly"
Expand All @@ -11288,7 +11287,8 @@
"name": "basescout",
"url": "https://explorerl2new-orderly-l2-4460-sepolia-8tc3sd7dvy.t.conduit.xyz",
"icon": "blockscout",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"shortName": "orderlyl2"
Expand Down Expand Up @@ -11697,7 +11697,8 @@
"name": "blockscout",
"url": "https://explorer.publicgoods.network",
"icon": "blockscout",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"shortName": "PGN"
Expand Down Expand Up @@ -13931,7 +13932,8 @@
"name": "blockscout",
"url": "https://explorer.sepolia.publicgoods.network",
"icon": "blockscout",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"shortName": "sepPGN"
Expand Down Expand Up @@ -14789,7 +14791,8 @@
{
"name": "Synapse Chain Sepolia",
"url": "https://sepolia.synapsescan.com",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"shortName": "synapse-sepolia"
Expand Down Expand Up @@ -16963,7 +16966,8 @@
{
"name": "Zora Network Explorer",
"url": "https://explorer.zora.energy",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"shortName": "zora"
Expand All @@ -16984,7 +16988,8 @@
{
"name": "Zora Sepolia Testnet Network Explorer",
"url": "https://sepolia.explorer.zora.energy",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"shortName": "zsep"
Expand Down
39 changes: 22 additions & 17 deletions config/explorers.json
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,8 @@
"name": "orderlyscout",
"url": "https://explorer.orderly.network",
"icon": "blockscout",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"295": [
Expand Down Expand Up @@ -1360,14 +1361,16 @@
"name": "blockscout",
"url": "https://explorer.publicgoods.network",
"icon": "blockscout",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"444": [
{
"name": "Synapse Chain Sepolia",
"url": "https://sepolia.synapsescan.com",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"456": [
Expand Down Expand Up @@ -1686,7 +1689,8 @@
{
"name": "modescout",
"url": "https://sepolia.explorer.mode.network",
"standard": "none"
"standard": "none",
"iframe": true
}
],
"927": [
Expand Down Expand Up @@ -3012,7 +3016,8 @@
"name": "basescout",
"url": "https://explorerl2new-orderly-l2-4460-sepolia-8tc3sd7dvy.t.conduit.xyz",
"icon": "blockscout",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"4689": [
Expand Down Expand Up @@ -3425,8 +3430,7 @@
{
"name": "Bitrock Testnet Explorer",
"url": "https://testnetscan.bit-rock.io",
"standard": "EIP3091",
"iframe": true
"standard": "EIP3091"
}
],
"7777": [
Expand Down Expand Up @@ -3518,8 +3522,7 @@
{
"name": "alphscan",
"url": "https://explorer.alph.network",
"standard": "EIP3091",
"iframe": true
"standard": "EIP3091"
}
],
"8848": [
Expand Down Expand Up @@ -4530,8 +4533,7 @@
"name": "blockscout",
"url": "https://blockexplorer.electroneum.com",
"icon": "electroneum",
"standard": "EIP3091",
"iframe": true
"standard": "EIP3091"
}
],
"54211": [
Expand Down Expand Up @@ -4602,7 +4604,8 @@
"name": "blockscout",
"url": "https://explorer.sepolia.publicgoods.network",
"icon": "blockscout",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"59140": [
Expand Down Expand Up @@ -4892,8 +4895,7 @@
{
"name": "scoville-explorer",
"url": "https://scoville-explorer.chiliz.com",
"standard": "none",
"iframe": true
"standard": "none"
}
],
"88888": [
Expand Down Expand Up @@ -5661,7 +5663,8 @@
{
"name": "Zora Network Explorer",
"url": "https://explorer.zora.energy",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"8007736": [
Expand Down Expand Up @@ -5918,7 +5921,8 @@
{
"name": "Zora Sepolia Testnet Network Explorer",
"url": "https://sepolia.explorer.zora.energy",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"1146703430": [
Expand Down Expand Up @@ -6051,7 +6055,8 @@
{
"name": "a8scan-testnet",
"url": "https://testnet.a8scan.io",
"standard": "EIP3091"
"standard": "EIP3091",
"iframe": true
}
],
"4216137055": [
Expand Down
36 changes: 21 additions & 15 deletions scripts/getExplorerInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const path = require("path");
const config = require("../config/app");
const fetch = require("node-fetch");

const BATCH_SIZE = 35;
const BATCH_TIMEOUT = 8;
const CALL_TIMEOUT = 16;
const BATCH_SIZE = 50;
const BATCH_TIMEOUT = 6;
const CALL_TIMEOUT = 14;

const main = async () => {
const startTime = Date.now();
Expand All @@ -31,8 +31,6 @@ const main = async () => {
chain.rpc &&
chain.rpc.length > 0
) {
if (chain.title && chain.title.length < 50) chain.name = chain.title;

rawChains.push(chain);
}
} catch (e) {}
Expand Down Expand Up @@ -77,22 +75,30 @@ const main = async () => {

promises.push(
fetch(explorer.url, {
method: "HEAD",
timeout: CALL_TIMEOUT * 1000,
})
.then((res) => {
if (
!res.headers.raw()["x-frame-options"] &&
!res.headers.raw()["X-Frame-Options"]
) {
const headers = res.headers.raw();
let allowsIframes = true;

if (headers["x-frame-options"] || headers["X-Frame-Options"]) {
allowsIframes = false;
}
const csp =
headers["content-security-policy"] ||
headers["Content-Security-Policy"];
if (csp && csp.length) {
csp.forEach((p) => {
if (p.includes("frame-ancestors")) allowsIframes = false;
});
}

if (allowsIframes === true) {
chains[i].explorers[j].iframe = true;
}

console.log(
"iframe:",
!!chains[i].explorers[j].iframe,
chain.name,
explorer.url
);
console.log("iframe:", allowsIframes, chain.name, explorer.url);
})
.catch(() => {
chains[i].explorers[j].failed = true;
Expand Down

0 comments on commit 46a47b9

Please sign in to comment.