User:Nixinova/Newest article.js

(function {   function link(target, text) {        if (!text) {            text = target;        }        return '' + text + '';    }    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(`                                                                 `); $('#page-count').html(                     'Total pages: ' + Number(page_count).toLocaleString + ' '                    ); $('#article-count').html(                     'Total articles: ' + Number(article_count).toLocaleString + ' '                    ); $('#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