Jump to content

User:Djsasso/SimpleWPTab.js

From Wikipedia, the free encyclopedia
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.
var simpletabMainTab = $('#left-navigation li:not(.selected)').slice(0,1).css('opacity','0.9');
var simpletabTab = simpletabMainTab.clone(true).attr('id', simpletabMainTab.attr('id')+'-').css('opacity','0.9').removeClass('new');
var simpletabURL = 'http://' + 'simple.wikipedia.org/wiki/' + mw.config.get('wgPageName');
 
simpletabTab.find('a').attr('href', simpletabURL).empty().text('Simple').attr('title', "Navigate to this page on Simple Wikipedia");

$.ajax({
   url:"http://simple.wikipedia.org/w/api.php?action=query&titles=" + encodeURIComponent(mw.config.get('wgPageName')) + "&format=xml", 
   dataType: "xml", 
   type: "GET",
   success:parseIt
});

function parseIt (xml){
   var missing = $(xml).find('page').attr('missing');
   if (typeof missing != "undefined") simpletabTab.addClass('new');
}

simpletabTab.insertBefore($('#right-navigation li').slice(0,1));