User:NQ/custom-scripts/tabs.js

// Tweaks to user:js/6tabs-vector and [[User:Equazcion/ContribsTabVector.js] for better navigation.

//user:js/6tabs-vector function sixTabs { if (!window.sixTabsNames) { sixTabsNames = { 'history': 'History', };	}	var main = $('#left-navigation li:not(.selected)').slice(0, 1).css('opacity', '0.9'); if (!main.hasClass('new')) { var url = main.find('a').attr('href'); dup('history'); }

function dup(type) { var tab = main.clone(true).attr('id', main.attr('id') + '-' + type).insertAfter(main).css('opacity', '0.6'); tab.find('a').attr('href', url + '?action=' + type).attr('title', type); nameTab(tab, type); }	main = $('#right-navigation li.selected').removeClass('selected'); if (main.hasClass('new')) { //... join with ca-edit on new page if ($('#ca-edit').hide.hasClass('selected')) { main.addClass('selected'); }	} else { //...join with ca-view ("Read"), copying href in case of FlaggedRevs if ($('#ca-view').hide.hasClass('selected')) { main.addClass('selected'); }		main.find('a').attr('href', $('#ca-view').find('a').attr('href')); }

function nameTab(tab, type) { var name = sixTabsNames[type] || type; if (!name) return; tab = tab.find('a').empty; if (/\.(png|svg|gif)$/.test(name)) $(' ').attr('src', '//upload.wikimedia.org/wikipedia/' + name).attr('width', '18').appendTo(tab); else tab.text(name); }	//[[User:Equazcion/ContribsTabVector.js]	mw.loader.using(['mediawiki.util', 'mediawiki.Uri'], function {		"use strict";		var username = mw.config.get('wgRelevantUserName');		if (!username) {			return; 		}		var firstTab = $('#p-views ul li').eq(0);  		var contribsTabUrl = mw.util.getUrl('Special:Contributions', {			target: username,			limit: 100		});		mw.util.addPortletLink('p-views', contribsTabUrl, 'Contrib', 'ca-contributions', 'Show this user\'s contributions', null, firstTab);	}); } if (mw.config.get('skin') == 'vector' && mw.config.get('wgNamespaceNumber') >= 0) {	$(sixTabs); }