User:Theleekycauldron/Million award checker.js

Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
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
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy