Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
var galleries = [ 'Arthropods', 'Birds', 'Mammals', 'Other animals', 'Plants and fungi', 'Bones', 'People', 'Paintings', 'Settlements', 'Castles', 'Religious Buildings', 'Constructions and buildings', 'Artificially illuminated outdoor spaces', 'Infrastructure', 'Frescos, ceilings and stained glass', 'Interiors and details', 'Panoramic views', 'Nature views', 'Waters', 'Astronomy', 'Maps', 'Vehicles and crafts', 'Objects, rocks and miscellaneous', 'Videos and Animations' ];
var linksurl = 'https://commons.wikimedia.org/w/api.php?action=parse&prop=links&format=json&page=Commons:Picture_of_the_Year/2014/R1/Gallery/';
var parseurl = 'https://commons.wikimedia.org/w/api.php?action=parse&prop=links&format=json&redirects&page=';

function getStats() {

 var y = 0;
 var table = '<pre>{| class="wikitable sortable"\n|-\n! # !! Galleri !! Bild !! Röster';

 for( var k = 0; k < galleries.length; k++ ) {
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.open( 'GET', linksurl + galleries[k], false );
  xmlhttp.send( null );

  var links = eval( '(' + xmlhttp.responseText + ')' ).parse.links;

  for( var i = 0; i < links.length; i++ ) {
   if( links[i]['*'].match( 'Commons:Picture of the Year/2014/R1/v/' ) && links[i]['exists'] == "" ) {
    var url = parseurl + links[i]['*'].replace( '&', '%26' );
    xmlhttp = new XMLHttpRequest();
    xmlhttp.open( 'GET', url, false );
    xmlhttp.send( null );
    var votelinks = eval( '(' + xmlhttp.responseText + ')' ).parse.links;
    document.getElementById( 'searchInput' ).value = ++y;
    var count = 0;
    for( var x = 0; x < votelinks.length; x++ ) {
     if( votelinks[x].ns == 2 ) {
      count++;
     }
    }
    table = table + '\n|-\n| ' + y + ' || ' + galleries[k] + ' || [[' + links[i]['*'] + ']] || ' + count;
   }
  }
 }
 document.getElementById( 'wikiPreview' ).innerHTML = table;
}

$( getStats );