User:Theleekycauldron/Million award checker.js

try { let api = new mw.Api; } catch (SyntaxError) {} function httpGet(theUrl) { //from StackOverflow; puts a GET request to an API (we'll use it to query pageviews) var xmlHttp = new XMLHttpRequest; //it does stuff xmlHttp.open( "GET", theUrl, false ); // false for synchronous request xmlHttp.send( null ); return xmlHttp.responseText; } function getPage(article){ jsonobj = JSON.parse(httpGet("https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia/all-access/user/"+article.replaceAll(/ /g,"_").replaceAll(/ /g,"_").replaceAll("/","%2F").replaceAll("?","%3F")+"/daily/2021010100/2021123100")); sum = 0 for (item of jsonobj.items){ sum += item.views }  return sum }