User:Hydriz/global.js

// /** * The global JS file for Hydriz * * This is the global JS file purely designed for User:Hydriz. * * When editing this page, please hardcode the URL to the script as * things might break when simply importing script from local page. * * After editing this page, please bypass cache by refreshing using * Ctrl+F5. Changes here will affect wikis throughout Wikimedia * Foundation and certain external wikis, please use with care. * * @author Hydriz */

/** Special functions **/ // Check if string is in array function userHydrizin_array( string, array ) { var i = ''; for (i in array) { if (array[i] == string) { return true; }		}	return false; }

// Make the first letter uppercase function userHydrizucfirst( string ) { return string[0].toUpperCase + string.slice(1); }

// Check if a string ends with a suffix function userHydrizendsWith( string, suffix ) { return string.match( suffix+"$" ) == suffix; }

/** Administration **/ // Sysop tools (only activated if sysop on that wiki) if ( userHydrizin_array( "sysop", mw.config.get( "wgUserGroups" ) ) ) { // Clean delete reasons jQuery( document ).ready( function {		if ( mw.config.get('wgAction') == 'delete' ) {			var wpReason = document.getElementById( 'wpReason' );			if ( !wpReason ) {				return;			}			var regexp = /(content was|page was empty|content before blanking was)/i;			if ( regexp.test( wpReason.value ) ) {				wpReason.value = '';			}		}	} );

// Adds some links to Special:Block mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:Gadget-blockoptions.js&action=raw&ctype=text/javascript');

// Mass deletions of pages (Implements Special:MassDelete) mw.loader.load('//incubator.wikimedia.org/w/index.php?title=MediaWiki:Gadget-massdelete.js&action=raw&ctype=text/javascript');

// Add "User rights" link in the tab if ( userHydrizin_array( mw.config.get('wgNamespaceNumber'), [2, 3] ) ) { mw.util.addPortletLink( 'p-cactions', mw.config.get('wgScript') + '?title=Special:UserRights&user=' + encodeURIComponent( mw.config.get('wgTitle').split('/')[0] ),			'Rights', 'ca-rights', 'Change user rights' ); } }

/** Usability improvements and tools **/ // UTC Live clock mw.loader.load('//www.mediawiki.org/w/index.php?title=MediaWiki:Gadget-UTCLiveClock.js&action=raw&ctype=text/javascript');

// Adds a link to Special:PrefixIndex and Special:Log mw.loader.using(['mediawiki.util', 'mediawiki.user'], function {	$(document).ready(function  { // Clone .mw-contributions-footer to the top as well if (mw.config.get('wgCanonicalSpecialPageName') === 'Contributions' && $('.mw-contributions-footer').length) { $('#contentSub').after($('.mw-contributions-footer').prop('outerHTML')); }

// Extra links in personal topbar mw.util.addPortletLink('p-tb', mw.util.getUrl('Special:Prefixindex/' + mw.config.get('wgPageName')), 'Subpages', 'tb-prefixindex'); mw.util.addPortletLink('p-personal', mw.util.getUrl( 'Special:Log/' + mw.user.getName ), 'Logs', 'pt-mylogs', null, null, '#pt-logout'); }); });

// A tool for editing TemplateData information mw.loader.load('//fr.wikipedia.org/w/index.php?title=Utilisateur:Ltrlg/scripts/TemplateDataEditor.js&action=raw&ctype=text/javascript');

// HotCat: A tool for easier editing of categories mw.loader.load('//commons.wikimedia.org/w/index.php?title=MediaWiki:Gadget-HotCat.js&action=raw&ctype=text/javascript');

// PurgeTab: Add links to purge, hard purge and perform a null edit on pages mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:Gadget-PurgeTab.js&action=raw&ctype=text/javascript');

// Adds information on userpages listing their flags, account-age, contributions-count, and last-edit-time mw.loader.load('//en.wikipedia.org/w/index.php?title=User:PleaseStand/userinfo.js&action=raw&ctype=text/javascript');

// MoreMenu: Provides a dropdown of additional links related to the page/user mw.loader.load('https://meta.wikimedia.org/w/index.php?action=raw&ctype=text/javascript&title=MediaWiki:MoreMenu.import.js');

/** Shortcuts **/ /** * Redirect User:Name/skin.js and skin.css to the current skin's pages * (unless the 'skin' page really exists) * @source mediawiki.org/wiki/Snippets/Redirect_skin.js * @rev 3 */ mw.loader.using( 'mediawiki.util', function {	if ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgNamespaceNumber' ) === 2 ) {		var titleParts = mw.config.get( 'wgPageName' ).split( '/' );		// Make sure there was a part before and after the slash		// And that the latter is 'skin.js' or 'skin.css'		if ( titleParts.length == 2 ) {			var userSkinPage = titleParts[0] + '/' + mw.config.get( 'skin' );			if ( titleParts[1] === 'skin.js' ) {				window.location.href = mw.util.getUrl( userSkinPage + '.js' );			} else if ( titleParts[1] === 'skin.css' ) {				window.location.href = mw.util.getUrl( userSkinPage + '.css' );			}		}	} });

// The following converts the page title to be interwiki-friendly if ( mw.config.get( 'wgNamespaceNumber' ) == 4 ) { var userHydrizInterwikiPage = "Project" + mw.config.get('wgPageName').substring(mw.config.get('wgFormattedNamespaces')[4].length); } else if ( mw.config.get ( 'wgNamespaceNumber' ) == 5 ) { var userHydrizInterwikiPage = "Project talk" + mw.config.get('wgPageName').substring(mw.config.get('wgFormattedNamespaces')[5].length); } else { var userHydrizInterwikiPage = mw.config.get('wgPageName'); }

/** * Wiki-specific tools * This section allows scripts to be loaded on specific wikis instead * of having to modify the local Special:MyPage/skin.js page. * Please note that importing scripts here still requires the use of * mw.loader.load and not importScript. */ if ( ( mw.config.get( 'wgServer' ) == '//commons.wikimedia.org' ) || ( mw.config.get( 'wgServer' ) == '//commons.wikimedia.beta.wmflabs.org' ) ) { // Easy reviewing of Flickr images transferred to Commons mw.loader.load('//commons.wikimedia.org/w/index.php?title=User:Patstuart/Flickrreview.js&action=raw&ctype=text/javascript'); // Enable Twinkle on Commons mw.loader.load('//commons.wikimedia.org/w/index.php?title=User:Kanonkas/twinkle.js&action=raw&ctype=text/javascript'); } else if ( ( mw.config.get( 'wgServer' ) == '//en.wikipedia.org' ) || ( mw.config.get( 'wgServer' ) == '//en.wikipedia.beta.wmflabs.org' ) ) { // AfC Redirect Helper script mw.loader.load('//en.wikipedia.org/w/index.php?title=User:The_Earwig/afc-helper.js&action=raw&ctype=text/javascript'); // Easy tagging of stubs mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Ais523/stubtagtab2.js&action=raw&ctype=text/javascript'); // Easy fixing of dashes mw.loader.load('//en.wikipedia.org/w/index.php?title=User:GregU/dashes.js&action=raw&ctype=text/javascript'); } else if ( ( mw.config.get( 'wgServer' ) == '//simple.wikipedia.org' ) || ( mw.config.get( 'wgServer' ) == '//simple.wikipedia.beta.wmflabs.org' ) ) { var enwplink = '//en.wikipedia.org/wiki/Special:Search/' + userHydrizInterwikiPage; mw.util.addPortletLink( 'p-tb', enwplink, 'English', 't-enwp', 'English Wikipedia page', 't', '#t-print' ); } else if ( mw.config.get( 'wgServer' ) == '//simple.wiktionary.org' ) { // Local fix of the creation script mw.loader.load('//simple.wiktionary.org/w/index.php?title=User:Hydriz/creation.js&action=raw&ctype=text/javascript'); var sewplink = '//simple.wikipedia.org/wiki/Special:Search/' + userHydrizucfirst( userHydrizInterwikiPage ); var enwtlink = '//en.wiktionary.org/wiki/Special:Search/' + userHydrizInterwikiPage; mw.util.addPortletLink( 'p-tb', sewplink, 'Wikipedia', 't-sewp', 'Find Wikipedia article', 'w', '#t-print' ); mw.util.addPortletLink( 'p-tb', enwtlink, 'Wiktionary', 't-enwt', 'English Wiktionary entry', 't', '#t-print' ); } else if ( ( mw.config.get( 'wgServer' ) == '//en.wikisource.org' ) || ( mw.config.get( 'wgServer' ) == '//en.wikisource.beta.wmflabs.org' ) ) { // Allows for quick creation of pages without text mw.loader.load('//en.wikisource.org/w/index.php?title=MediaWiki:Gadget-Without text.js&action=raw&ctype=text/javascript'); // Checks if the brackets matches mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Ais523/bracketmatch.js&action=raw&ctype=text/javascript'); } else if ( ( mw.config.get( 'wgServer' ) == '//www.wikidata.org' ) || ( mw.config.get( 'wgServer' ) == '//wikidata.org' ) ) { // Scored revisions for vandalism-tracking on Wikidata mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:He7d3r/Tools/ScoredRevisions.js&action=raw&ctype=text/javascript'); // Recoin: Relative completeness indicator mw.loader.load('//www.wikidata.org/w/index.php?title=User:Vvekbv/recoin_id.js&action=raw&ctype=text/javascript'); } else if ( mw.config.get( 'wgServer' ) == '//meta.wikimedia.org' ) { // Automatically create local accounts mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Krinkle/Tools/Global_SUL.js&action=raw&ctype=text/javascript'); }

if ( userHydrizendsWith( mw.config.get( 'wgServer' ), 'wikipedia.org' ) ) { // Script for viewing information from Wikidata underneath the page title mw.loader.load("//www.wikidata.org/w/index.php?title=User:Yair rand/WikidataInfo.js&action=raw&ctype=text/javascript"); } else if ( userHydrizendsWith( mw.config.get( 'wgServer' ), 'beta.wmflabs.org' ) ) { // Add some steward tools mw.loader.load('//tools-static.wmflabs.org/meta/scripts/pathoschild.stewardscript.js'); }

/** Anti-vandalism tools **/ // Gives some useful links on user, user talk and user contribution pages mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/useful_links.js&action=raw&ctype=text/javascript');

// Smart rollback mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/smart_rollback.js&action=raw&ctype=text/javascript');

// Tag pages fast. // IMPORTANT: This script must be placed at the end of this file! // Adding support for some special wikis that do not use the standard deletion template var speedyTemplates = { '//commons.wikimedia.org': 'speedydelete', '//en.wikisource.org': 'sdelete', '//www.mediawiki.org': 'speedy', '//ml.wikipedia.org': 'SD' }; // Globally recognized template var speedyTemplate = "delete"; if ( mw.config.get( 'wgServer' ) in speedyTemplates ) { speedyTemplate = speedyTemplates[ mw.config.get( 'wgServer' ) ]; } mw.loader.load('//meta.wikimedia.org/w/index.php?title=User:Hoo_man/tagger.js&action=raw&ctype=text/javascript'); if(typeof(taggerConfig) == 'undefined') taggerConfig = {}; taggerConfig.tags = []; taggerConfig.editSummary = []; taggerConfig.tags[1] = ''; taggerConfig.editSummary[taggerConfig.tags[1]] = 'Nominating page for deletion'; taggerConfig.tags[2] = ''; taggerConfig.editSummary[taggerConfig.tags[2]] = 'Nominating page for deletion'; taggerConfig.tags[3] = ''; taggerConfig.editSummary[taggerConfig.tags[3]] = 'Nominating page for deletion'; // Special tags for the Simple English wikis if ( mw.config.get( 'wgServer' ) == '//simple.wiktionary.org' ) { taggerConfig.tags[4] = ''; taggerConfig.editSummary[taggerConfig.tags[4]] = 'Adding link to Wikipedia'; } // All others (custom tagging) taggerConfig.tags['other'] = 'Other -> (Please give an edit summary as well)'; //