Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page.
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.
// Modified from [[User:Equazcion/CatListMainTalkLinks.js]] ([[Special:PermaLink/778892707]])// Show a history link as wellif(mw.config.get('wgNamespaceNumber')===14){// Make sure we're in Category space// Grab page list elementsvarpages=$('#mw-pages li');$.each(pages,function(k,page){// Work with the link within each list element from now onpage=$(page).find('a');// Clone the linkvarpageClone=page.clone(true);// If the link isn't a talk page, start constructing the talk page linkif(page.attr('href').indexOf('talk:')===-1&&pageClone.attr('href').indexOf('Talk:')===-1){pageClone.text('talk');vart=mw.Title.newFromText(pageClone.attr('title'));if(t){t.getTalkPage();pageClone.attr('title',t.getPrefixedText());pageClone.attr('href','/wiki/'+t.getPrefixedDb());}}else{// If the link IS a talk page, start constructing the main page linkpageClone.text('main');varm=mw.Title.newFromText(pageClone.attr('title'));if(m){m.getSubjectPage();pageClone.attr('title',m.getPrefixedText());pageClone.attr('href','/wiki/'+m.getPrefixedDb());}}// Link is done, just need to check if the target exists so we can turn it red if not.// Grab link tooltip (as it now conveniently contains the page title alone, which we need for the Ajax query)varcloneTitle=pageClone.attr('title');varhistLink=$(page).clone(true);histLink.text('hist');histLink.attr('class','plainlinks');histLink.attr('href','/w/index.php?title='+encodeURI(page.text().replace(/ /g,'_'))+'&action=history');// Get target's "title" data from MediaWiki API$.ajax({url:mw.util.wikiScript('api')+'?action=query&titles='+encodeURIComponent(cloneTitle)+'&format=xml',dataType:'xml',type:'GET',success:parseIt});// If Ajax result shows the target doesn't exist, add "new" class to the link to turn it redfunctionparseIt(xml){varmissing=$(xml).find('page').attr('missing');if(typeofmissing!=='undefined'){pageClone.addClass('new');}}// Insert the constructed link after the existing one, along with space and parenthesispageClone.insertAfter(page).before('| ').after(')');histLink.insertAfter(page).before(' (').after(' ');});}