window.cache ??= {};
country='NOR';
demonym='Norwegian';
cat='U18';
(async () => {
let output = '';
for (const gen of ['women', 'men'])
for (const env of ['outdoor', 'indoor']) {
output += `===${cat} ${gen} ${env}===
{| class="wikitable sortable" style="font-size: 90%; width: 95%;"
|-
! Event !! Record !! Athlete !! Date !! Meet !! Place !! Country !! Age !! Ref
|-
`;
const rows = [];
for (const evt of {
outdoor: [
"100",
"200",
"400",
"800",
"1500",
"Mile",
"3000",
"5000",
"10000",
"2000S",
"3000S",
gen === 'women' ? "100H" : "110H",
"400H",
"HJ",
"PV",
"LJ",
"TJ",
"SP",
"DT",
"HT",
"JT",
gen === 'women' ? "Hep" : "Dec"
],
indoor: [
"60",
"200",
"400",
"800",
"1500",
"Mile",
"3000",
"5000",
"60H",
"HJ",
"PV",
"LJ",
"TJ",
"SP",
"WT",
gen === 'women' ? "Pen" : "Hep",
]}[env]) {
const url = `/api/lists/alltime/${country}/${env}/${cat}/${gen}/${evt}?&top=10`;
console.log(url);
const data = cache[url] ??= await (await fetch(url, {
headers: {
Authorization: new Function([...document.querySelectorAll('script:not([src]):not([type])')].at(-1).innerText+'return auth')(),
},
})).json()
const div = data.templates[0].divs[0];
const res = div.tables[0].body[0];
if (!res) continue;
if (res.venue === 'Saint-Denis') res.venue = 'Paris';
const wikiVenue = res.venueCountry === 'USA' ? res.venue : `${res.venue}, ${res.venueCountryFull}`;
const ayd = res.dateOfBirth ? `{{ayd|${res.dateOfBirth}|${res.date}}}` : res.yearOfBirth ? `{{age in years|${res.yearOfBirth}|${res.date}}} years` : '';
rows.push(`| [[${div.title.replace('One Mile', 'Mile run')}]] || ${res.result} || [[${res.name}]] || {{dts|abbr=on|${res.date}|format=dmy}} || ${res.competitionLong ?? ''} || [[${wikiVenue}|${res.venue}]] || {{flagg|cncie|${res.venueCountry}}} || ${ayd} || <ref>{{cite web |url-access=subscription |title=Tilastopaja - ${demonym} ${cat} ${data.indoor} ${data.gender}'s ${div.title} |url=https://www.tilastopaja.eu/beta/lists/alltime/${country}/${data.indoor}/${cat}/${gen}/${evt}?top=10 |website=www.tilastopaja.eu |access-date=${new Date().toISOString().split('T')[0]}}}</ref>`);
}
output += rows.join('\n|-\n') + '\n|}\n\n';
}
console.log(output);
return output;
})()