Documentation may be created at User:Nixinova/Newest article.js/doc.
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.
(function() {
function link(target, text) {
if (!text) {
text = target;
}
return '<a href="https://minecraft.gamepedia.com/' + target + '">' + text + '</a>';
}
function update() {
if ($('title').text() == 'User:Nixinova/Newest article – Official Minecraft Wiki') {
$.ajax({
url: 'https://minecraft.gamepedia.com/api.php?action=query&meta=siteinfo&siprop=statistics&list=recentchanges&rctype=new&rcprop=title|user&rcshow=!redirect&format=json',
dataType: 'jsonp'
}).done(function(data) {
let page_title = data.query.recentchanges[0].title;
let page_user = data.query.recentchanges[0].user;
page_text = 'The newest page is ' + link(page_title) + ', created by ' + link('User:' + page_user, page_user) + '.';
$.ajax({
url: 'https://minecraft.gamepedia.com/api.php?action=query&meta=siteinfo&siprop=statistics&list=recentchanges&rctype=new&rcnamespace=0&rcprop=title|user&rcshow=!redirect&format=json',
dataType: 'jsonp'
}).done(function(data) {
let article_title = data.query.recentchanges[0].title;
let article_user = data.query.recentchanges[0].user;
let article_count = data.query.statistics.articles;
let page_count = data.query.statistics.pages;
let article_text = 'The newest article is ' + link(article_title) + ', created by ' + link('User:' + article_user, article_user) + '.';
let now = new Date();
let updated = 'Last updated: ' +
now.getUTCFullYear() + '-' +
(now.getUTCMonth()+1).toString().padStart(2, '0') + '-' +
now.getUTCDate() + ' ' +
now.getUTCHours().toString().padStart(2, '0') + ':' +
now.getUTCMinutes().toString().padStart(2, '0') + ':' +
now.getUTCSeconds().toString().padStart(2, '0') + ' (UTC)';
$('#notice').html(`
<div style="text-align: center;">
<p id="intro"></p>
<div style="display: flex; width: 100%;">
<div id="page-count" style="width: 50%;"></div>
<div id="article-count" style="width: 50%;"></div>
</div>
<p id="page-text"></p>
<p id="article-text"></p>
<p id="updated"></p>
</div>
`);
$('#page-count').html(
'Total pages:<br><div style="font-size:500%">' + Number(page_count).toLocaleString() + '</div>'
);
$('#article-count').html(
'Total articles:<br><div style="font-size:500%">' + Number(article_count).toLocaleString() + '</div>'
);
$('#page-text').html(window.page_text);
$('#article-text').html(article_text);
$('#updated').html(updated);
});
});
}
}
$(function() {
update();
setInterval(update, 10000);
});
})();
// Adapted from https://tools.wmflabs.org/five-million/script.js?2