ميدياويكي:Gadget-ContribsTabVector.js

ملاحظة: بعد الحفظ، قد يلزمك إفراغ الكاش لرؤية التغييرات (إفراغ الكاش الآن).

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

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

    importScript('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.

*/

if (mw.config.get('wgNamespaceNumber') == 2 || mw.config.get('wgNamespaceNumber') == 3) { // Don't do anything unless we're in user or usertalk space

  // Set default options for any that haven't been set
  if (contribsTabName == null) var contribsTabName = "مساهمات";
  if (contribsTabNumber == null) var contribsTabNumber = 50;
  if (contribsTabStats == null) var contribsTabStats = true;
  if (contribsTab == null) var contribsTab = true;
  if (contribsTabStatsName == null) var contribsTabStatsName = "إحصاءات";
  
  // Get the current page's username
  var username = mw.config.get('wgTitle').split("/")[0];

  // Grab main page tab, remove 'new' class in case it was red
  var main = $('#left-navigation li:not(.selected)').slice(0,1).css('opacity','0.9').removeClass('new');
  
  if (contribsTab) { // Construct the contribs tab, if it's not turned off

     // Clone main page tab
     var tabContribs = main.clone(true).attr('id', main.attr('id')+'-').css('opacity','0.9');

     // Construct contribs URL
     var contribsTabURL = 'http://ar.' + wgNoticeProject + '.org/w/index.php?title=Special:Contributions&target=' +
                           username + '&limit=' + contribsTabNumber + '&uselang=ar';
     // Set contribs tab URL, text, and tooltip
     tabContribs.find('a').attr('href', contribsTabURL).empty().text(contribsTabName).attr('title', "إظهار مساهمات المستخدم");

  }

  if (contribsTabStats) { // Construct the stats tab, if it's not turned off
     
     // Clone main page tab
     var tabStats = main.clone(true).attr('id', main.attr('id')+'-').css('opacity','0.9');
     
     // Construct stats URL
     var contribsTabStatsURL = 'http://tools.wmflabs.org/~tparis/pcount/index.php?name=' + username + '&lang=ar&wiki=' + wgNoticeProject;

     // Set stats tab URL, text, and tooltip
     tabStats.find('a').attr('href', contribsTabStatsURL).empty().text(contribsTabStatsName).attr('title', "إظهار إحصاءات تعديلات المستخدم");

  }

  // Place constructed tabs (done here for easy ordering)
  if (contribsTabStats) tabStats.insertAfter(main);
  if (contribsTab) tabContribs.insertAfter(main);

}