diff --git a/index.html b/index.html index ec406bd38..13e17597c 100644 --- a/index.html +++ b/index.html @@ -7,12 +7,12 @@ polkadot{.js}/phishing @@ -70,24 +72,44 @@ setTimeout(() => window.requestAnimationFrame(draw), 25); } + function appendRow (date, url = '') { + const row = document.createElement('tr'); + const a = document.createElement('td'); + const b = document.createElement('td'); + + a.appendChild(document.createTextNode(url)); + + if (typeof date === 'string') { + b.appendChild(document.createTextNode(date)); + } else { + b.appendChild(date); + } + + row.appendChild(a); + row.appendChild(b); + + table.appendChild(row); + } + async function main () { draw(); const metaBody = await fetch('https://polkadot.js.org/phishing/urlmeta.json'); const metaJson = await metaBody.json(); + let prevMonth = ''; metaJson.forEach(({ date, url }) => { - const row = document.createElement('tr'); - const u = document.createElement('td'); - const d = document.createElement('td'); + const thisMonth = date.split('-').slice(0, 2).join('-'); - u.appendChild(document.createTextNode(url)); - d.appendChild(document.createTextNode(date)) + if (thisMonth !== prevMonth) { + const c = document.createElement('h3'); - row.appendChild(u); - row.appendChild(d); + c.appendChild(document.createTextNode(thisMonth)); + appendRow(c); + prevMonth = thisMonth; + } - table.appendChild(row); + appendRow(date, url); }); } diff --git a/scripts/sortAll.mjs b/scripts/sortAll.mjs index 98f327083..0bc58278b 100644 --- a/scripts/sortAll.mjs +++ b/scripts/sortAll.mjs @@ -30,6 +30,6 @@ fs.writeFileSync('urlmeta.json', `${JSON.stringify( .filter((url) => !urls.includes(url)) .map((url) => ({ date, url })) ) - .sort((a, b) => a.url.localeCompare(b.url)), + .sort((a, b) => b.date.localeCompare(a.date) || a.url.localeCompare(b.url)), null, 2 )}\n`); diff --git a/urlmeta.json b/urlmeta.json index a739875d1..8de36b3fc 100644 --- a/urlmeta.json +++ b/urlmeta.json @@ -3,34 +3,6 @@ "date": "2021-01-07", "url": "4dot.net" }, - { - "date": "2020-10-18", - "url": "dothereum-polkadot.net" - }, - { - "date": "2021-01-06", - "url": "polkadot-airdrop.info" - }, - { - "date": "2021-01-06", - "url": "polkadot-airdrop.live" - }, - { - "date": "2020-10-14", - "url": "polkadot-dot.info" - }, - { - "date": "2020-12-30", - "url": "polkadot-wallet.com" - }, - { - "date": "2020-12-02", - "url": "polkadot.com.se" - }, - { - "date": "2020-12-30", - "url": "polkadotfund.com" - }, { "date": "2021-01-07", "url": "polkadots.network" @@ -39,6 +11,34 @@ "date": "2021-01-07", "url": "polkadotwallet-unlock.org" }, + { + "date": "2021-01-06", + "url": "polkadot-airdrop.info" + }, + { + "date": "2021-01-06", + "url": "polkadot-airdrop.live" + }, + { + "date": "2020-12-30", + "url": "polkadot-wallet.com" + }, + { + "date": "2020-12-30", + "url": "polkadotfund.com" + }, + { + "date": "2020-12-02", + "url": "polkadot.com.se" + }, + { + "date": "2020-10-18", + "url": "dothereum-polkadot.net" + }, + { + "date": "2020-10-14", + "url": "polkadot-dot.info" + }, { "date": "2020-10-14", "url": "polkawallets.site"