User:CaroFraTyskland/pv.js

var title = mw.config.get('wgPageName') data = { "action": "query", "format": "json", "prop": "pageviews", "titles": title, "formatversion": "2", "pvipmetric": "pageviews", "pvipdays": "1", "pvipcontinue": "" };	$.getJSON(mw.util.wikiScript('api'), data).then(getViews)

function getViews (json) { console.log(json) pageviews = json["query"]["pages"][0]["pageviews"]

day = Object.keys(pageviews)[0] views = pageviews[day]

if(views > 0) show_pv(views) }

function show_pv(view){ $(function { 		$info = $(' ')			.css({marginLeft: '1em', lineHeight: '1em'});		$('#firstHeading').append($info);        var txt = "(" + view + " views yesterday)"        if (view == 1)            txt = "(1 view yesterday)"		$info.text(txt)	}); }