1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
document.addEventListener("keydown", async (event) => {
if (event.key != ".") {
return;
}
if (document.activeElement != document.body) {
return;
}
event.preventDefault();
const [subdomain] = window.location.hostname.split(".");
const [author, name] = subdomain.split("-");
const resp = await fetch(`https://api.val.town/v1/alias/${author}/${name}`);
if (!resp.ok) {
console.error("failed to fetch val infos");
return;
}
const val = await resp.json() as { id: string };
window.open(`https://val.town/editor?id=${val.id}`);
});