User:Equazcion/ContribsTabVector.js

/* This script adds Contributions and Statistics tabs to User and User talk pages. For Vector skin.

This script was originally written by [[User:Equazcion]] and rewritten mostly from scratch by [[User:HueSatLum]].

To use this script, place the following line in your vector.js page:

	importScript('User:Equazcion/ContribsTabVector.js'); // Backlink: [[User:Equazcion/ContribsTabVector.js]]

Add any or all of these lines after the importScript line above to set various options (the default values are shown):

	var contribsTab = true;                    // Turns the Contributions tab on or off (set to false; for off)
	var contribsTabStats = true;               // Turns the Statistics tab on or off (set to false; for off)
	var contribsTabNumber = 50;                // Number of contributions to display in the Contributions tab. Can be 1 to 5000.
	var contribsTabName = "Contributions";     // Custom name for Contributions tab. Replace quoted text with your desired name.
	var contribsTabStatsName = "Statistics";   // Custom name for Statistics tab. Replace quoted text with your desired name.

-- End of documentation -- */

mw.loader.using( ['mediawiki.util', 'mediawiki.Uri'], function () {
	"use strict";
	var username, firstTab, contribsTabUrl, contribsTabStatsUrl;

	// Set default options for any that haven't been set
	function setDefault( option, val ) {
		if ( window[option] === undefined ) {
			window[option] = val;
		}
	}
	setDefault( 'contribsTabName', 'Contributions' );
	setDefault( 'contribsTabNumber', 50 );
	setDefault( 'contribsTabStats', true );
	setDefault( 'contribsTab', true );
	setDefault( 'contribsTabStatsName', 'Statistics' );

	username = mw.config.get( 'wgRelevantUserName' );
	if ( !username ) {
		return; // Don't do anything if we're not on a page with a relevant username (i.e. User or User talk)
	}

	firstTab = $( '#p-views ul li' ).eq( 0 ); // Tab to put the new tabs before (usually "Read")

	if ( window.contribsTab ) { // Construct the contribs tab, if it's not turned off
		// Construct contribs URL
		contribsTabUrl = mw.util.getUrl( 'Special:Contributions', {
			target: username,
			limit: window.contribsTabNumber
		} );

		mw.util.addPortletLink(
			'p-views',
			contribsTabUrl,
			window.contribsTabName,
			'ca-contributions',
			'Show this user\'s contributions',
			null,
			firstTab
		);
	}

	if ( window.contribsTabStats ) { // Construct the stats tab, if it's not turned off
		// Construct stats URL
		contribsTabStatsUrl = new mw.Uri( '//tools.wmflabs.org/xtools-ec/' )
			.extend( {
				user: username,
				project: mw.config.get( 'wgDBname' )
			} )
			.toString();

		mw.util.addPortletLink(
			'p-views',
			contribsTabStatsUrl,
			window.contribsTabStatsName,
			'ca-statistics',
			'Show this user\'s editing statistics',
			null,
			firstTab
		);
	}
} );

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.