async function get_pages(titles,rvprop,startid,rvdir) { // this does something or other to get the pages and shtuss; idk, i don't question it, it works
var url = "https://en.wikipedia.org/w/api.php";
titles = titles.replaceAll("&","%26").replaceAll("+","%2B");
var params = {
action: "query",
prop: "revisions",
titles: titles,
rvprop: rvprop,
rvslots: "main",
rvdir: rvdir,
formatversion: "2",
format: "json",
rvlimit: 200
};
if (startid !== null){
params.rvstartid = startid;
}
url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
const response = await fetch(url);
const json = await response.json();
console.log(json)
return json.query.pages;
}
async function get_section(title,section) { // this does something or other to get the pages and shtuss; idk, i don't question it, it works
var url = "https://en.wikipedia.org/w/api.php";
title = title.replaceAll("&","%26").replaceAll("+","%2B");
let pages;
var params = {
action: "parse",
prop: "wikitext",
page: title,
section: section,
formatversion: "2",
format: "json"
};
url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});
let a = fetch(url)
.then(function(response){return response.json();})
.then(function(response) {
pages = response.parse;
})
.catch(function(error){console.log(error,url);});
await a;
return pages;
}