Jump to content

User:HueSatLum/common.js

From Wikipedia, the free encyclopedia
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.
$( '#n-recentchanges' ).appendTo( '#p-navigation .body ul' );

importScript( 'User:HueSatLum/pendingChangesLink.js' ); // [[User:HueSatLum/pendingChangesLink.js]]
importScript( 'User:HueSatLum/pageInfo.js' ); // [[User:HueSatLum/pageInfo.js]]
importScript( 'User:HueSatLum/highlightMyEdits.js' ); // [[User:HueSatLum/highlightMyEdits.js]]

importScript( 'User:Shubinator/DYKcheck.js' );  // [[User:Shubinator/DYKcheck.js]]
importScript( 'User:Ais523/topcontrib.js' );  // [[User:Ais523/topcontrib.js]]
importScript( 'User:GregU/dashes.js' );  // [[User:GregU/dashes.js]]
importScript( 'User:PleaseStand/userinfo.js' );  // [[User:PleaseStand/userinfo.js]]
importScript( 'User:Js/urldecoder.js' );  // [[User:Js/urldecoder.js]]
importScript( 'User:Equazcion/SkipFileWizard.js' ); // [[User:Equazcion/SkipFileWizard.js]]
importScript( 'User:Ucucha/HarvErrors.js' ); // [[User:Ucucha/HarvErrors.js]]
importScript('User:Gary/nominations viewer.js'); // [[Wikipedia:Nominations Viewer]]
// importStylesheet( 'User:Rezonansowy/FloatHead.css' ); // [ [User:Rezonansowy/FloatHead.css]]

/**
 * Guard against accidental rollbacks and logouts
 */
$( '.mw-rollback-link a, #pt-logout' ).click( function () {
  return confirm( 'Are you sure you want to do that?' );
} );

/**
 * Add a link to a user's subpages
 */
var username = mw.config.get( 'wgRelevantUserName' ),
    namespace = mw.config.get( 'wgNamespaceNumber' ) === 3 ? 3 : 2;
if ( username ) {
  mw.loader.using( 'mediawiki.util', function () {
    mw.util.addPortletLink(
      'p-tb', // Toolbox ID
      mw.util.getUrl( 'Special:PrefixIndex', {
        prefix: username + '/',
        namespace: namespace,
        stripprefix: 1
      } ),
      'Subpages',
      't-subpages',
      'A list of this user\'s subpages',
      null, // accesskey
      '#t-log' // put it before the log link
    );
  } );
}

/**
 * Ability to toggle interlanguage links
 */
var numLanguages = $( '#p-lang .interlanguage-link' ).length;
if ( numLanguages > 1 && mw.config.get( 'skin' ) !== 'cologneblue' ) {
  $( '#p-lang ul' ).hide();
  var showText = '[Show ' + numLanguages + ' languages]';
  $( '<a>' )
    .attr( 'href', '#' )
    .css( 'font-size', 12 )
    .text( showText )
    .appendTo( '#p-lang > div' )
    .click( function ( evt ) {
      evt.preventDefault();
      var $showhide = $( this );
      $( '#p-lang ul' ).css( 'display', function( _ind, curVal ) {
        if ( curVal === 'none' ) {
          $showhide.text( '[Hide languages]' );
          return 'block';
        }
        else {
          $showhide.text( showText );
          return 'none';
        }
      } );
    } );
}

/**
 * Use Mediawiki UI for some buttons
 */
mw.loader.using( 'mediawiki.ui.button', function () {
  var progressiveButtons = [
    '#mw-fr-submit-accept',
    '.mw-history-compareselectedversions-button'
  ];
  var destructiveButtons = [
    '#mw-fr-submit-reject',
    '#mw-fr-submit-unaccept'
  ];
  
  $( progressiveButtons.join() ).addClass( 'mw-ui-button mw-ui-progressive' );
  $( destructiveButtons.join() ).addClass( 'mw-ui-button mw-ui-destructive' );
} );

/**
 * Make clicking "Mark all pages as visited"
 * on the watchlist much quicker

$( '#mw-watchlist-resetbutton' ).submit( function ( evt ) {
  evt.preventDefault();
  var submitBtn = $( '#mw-watchlist-resetbutton input[type="submit"]' ).prop( 'disabled', true );
  
  new mw.Api().post( {
    action: 'setnotificationtimestamp',
    entirewatchlist: '',
    token: mw.user.tokens.get( 'csrfToken' )
  } ).done( function () {
  	submitBtn.removeProp( 'disabled' );
    $( '.mw-changeslist-line-watched' )
      .removeClass( 'mw-changeslist-line-watched' )
      .addClass( 'mw-changeslist-line-not-watched' );
  } );
} );
 */