Created
March 8, 2023 09:44
-
-
Save kolyasapphire/146d90fc7e21e8459c68448a263c1819 to your computer and use it in GitHub Desktop.
Urbit repeating id parts finder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Star = { | |
point: number | |
patp: string // '~havrun-hasnum' | |
is_listed: boolean | |
ship_type: string // 'planet' | |
unbooted: boolean | |
time_listed: string | |
time_added: string | |
price_int: number | |
child_points: number | |
unspawned: boolean | |
currency: string // "ETH" | |
price_usd: null | |
price_eth: number | |
urbitex_contract: null | |
removed_by_exchange: null | |
} | |
const params = new URLSearchParams({ | |
type: 'planet', | |
price_min: '0', | |
price_max: '10000000', // 0.01 ETH | |
unbooted: '1', | |
sort_order: '-point', | |
unspawned: '1', | |
}) | |
const req = await fetch( | |
'https://urbitex.io:8000/get_listed_ships?' + params.toString() | |
) | |
const res = await req.json() | |
for (const x of res.data as Star[]) { | |
const halves = x.patp.replace('~', '').split('-') | |
const parts = halves.flatMap((x) => x.match(/.{1,3}/g)!) | |
if (parts[0] === parts[2] || parts[1] === parts[3]) { | |
console.log( | |
`https://urbitex.io/ship/~${parts[0] + parts[1]}-${parts[2] + parts[3]}` | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment