MediaWiki:Gadget-PortletLinks.js

// // Portlet Links // This script adds additional/custom links to the sidebar, // and additional/custom tabs at the top-right next to the Search Box. // https://www.mediawiki.org/wiki/ResourceLoader/Core_modules#addPortletLink //

var action = mw.config.get("wgAction"), server = mw.config.get("wgServer"), pageName = mw.config.get("wgPageName"), canonicalNamespace = mw.config.get("wgCanonicalNamespace");

// // last diff // Adds a tab which gives the latest diff for a page. // if ( canonicalNamespace != 'Special'     && action != 'edit'      && action != 'delete'      && action != 'watch'      && action != 'unwatch'      && action != 'protect' ){ $(document).ready(function{		mediaWiki.util.addPortletLink( "p-cactions",           //Tab (Action) server + "/index.php?title=" + encodeURIComponent(pageName) + "&diff=cur&oldid=prev", "last",                 //Name of Tab "ca-last",              //id "Show most recent diff", //Tooltip '2'                     //accesskey );	}); }

// // redirects // Adds a tab to the top of pages; when clicked it highlights all links on the page that are redirects. // if ( canonicalNamespace != 'Special'     && action != 'history'      && action != 'delete'      && action != 'watch'      && action != 'unwatch'      && action != 'protect'      && action != 'markpatrolled'      && action != 'rollback'      && document.URL.indexOf('diff=') <= 0 ){ var highlightRedirects = { tab_redirects : null, addStylesheetRule : function(tag, style) { var ss = document.styleSheets[0]; if (ss.insertRule)  ss.insertRule(tag + '{' + style + '}', ss.cssRules.length); else if (ss.addRule) ss.addRule(tag, style); },		run : function { highlightRedirects.addStylesheetRule('a.mw-redirect', 'color:black'); highlightRedirects.addStylesheetRule('a.mw-redirect', 'background-color:yellow'); highlightRedirects.addStylesheetRule('a.mw-redirect:visited', 'color:dimgrey'); highlightRedirects.addStylesheetRule('a.mw-redirect:visited', 'background-color:yellow'); },		install : function { with(highlightRedirects) { //Shouldn't use `with`? mediaWiki.util.addPortletLink ('p-cactions', 'javascript:highlightRedirects.run;' ,					'redirects', 'ca-redirects', 'Highlights all links which are redirects', 'r') || mediaWiki.util.addPortletLink ('views', 'javascript:highlightRedirects.run;', 					'redirects', 'ca-redirects', 'Highlights all links which are redirects', 'r'); }		}	};	$(document).ready(highlightRedirects.install); }

// -- // Page logs // Because they're not just for admins :P // Adds a link in the Tools section of the sidebar. // -- if (canonicalNamespace != "Special") { $(document).ready(function{		mediaWiki.util.addPortletLink("p-tb", "http://zeldawiki.org/index.php?title=Special%3ALog&type=&user=&page=" + pageName, "Page Logs", "t-logs", "Show all relevant logs for this page.", '3'		);	}); }