// ** "speciestabMainTab" is a variable you need to define before you clone it.
var speciestabMainTab = $('#left-navigation li:not(.selected)').slice(0,1).css('opacity','0.9');
// Clone main page tab
var speciestabTab = speciestabMainTab.clone(true).attr('id', speciestabMainTab.attr('id')+'-').css('opacity','0.9').removeClass('new');
// ** URL for wikispecies was messed up
var speciestabURL = 'http://' + 'species.wikimedia.org/wiki/' + wgPageName;
// Set WikiSpecies tab URL, text, and title
speciestabTab.find('a').attr('href', speciestabURL).empty().text('WikiSpecies').attr('title', "Navigate to this page on WikiSpecies");
// ** URL needed tweaking here: " + '/WikiSpecies' " isn't required and was messing things up.
$.ajax({
url:"http://species.wikimedia.org/w/api.php?action=query&titles=" + encodeURIComponent(mw.config.get('wgPageName')) + "&format=xml",
dataType: "xml",
type: "GET",
success:parseIt
});
// Ajax function on data return: If 'missing' field is defined, page is missing, so add 'new' class to tab, which turns it red
function parseIt (xml){
var missing = $(xml).find('page').attr('missing');
if (typeof missing != "undefined") speciestabTab.addClass('new');
}
speciestabTab.insertBefore($('#right-navigation li').slice(0,1));
// ** Making tab red still doesn't work for some reason, haven't figured that out yet,
// ** but the ajax url is correct as you can see if you navigate to it manually:
// ** http://species.wikimedia.org/w/api.php?action=query&titles=monkey&format=xml