Jump to content

User:JJMC89/common.js

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by JJMC89 (talk | contribs) at 01:06, 19 June 2018 (too hard to read). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
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.
// <nowiki>
lwgScript = mw.config.get( 'wgScript' );
lwgUserName = mw.config.get( 'wgUserName' );
lwgNamespaceNumber = mw.config.get( 'wgNamespaceNumber' );
lwgPageName = mw.config.get( 'wgPageName' );

function importMwScript( page, family, lang ) {
	$.when( $.ready, mw.loader.using( ['mediawiki.util'] ) ).then( function() {
		if ( typeof family === 'undefined' && typeof lang === 'undefined' ) {
			console.log( 'Loading ' + page );
			mw.loader.load( lwgScript + '?title=' + mw.util.wikiUrlencode( page ) + '&action=raw&ctype=text/javascript' );
		} else {
			if ( typeof family === 'undefined' ) {
				family = 'wikipedia';
			} else if ( typeof lang === 'undefined' ) {
				lang = 'en';
			}
			console.log( 'Loading script: ' + lang + ':' + family + ':' + page );
			mw.loader.load( '//' + mw.util.wikiUrlencode( lang + '.' + family + '.org' ) + lwgScript + '?title=' + mw.util.wikiUrlencode( page ) + '&action=raw&ctype=text/javascript' );
		}
	} );
}

function importMwStylesheet( page, family, lang ) {
	$.when( $.ready, mw.loader.using( ['mediawiki.util'] ) ).then( function() {
		if ( typeof family === 'undefined' && typeof lang === 'undefined' ) {
			console.log( 'Adding ' + page );
			mw.loader.load( lwgScript + '?title=' + mw.util.wikiUrlencode( page ) + '&action=raw&ctype=text/css', 'text/css' );
		} else {
			if ( typeof family === 'undefined' ) {
				family = 'wikipedia';
			} else if ( typeof lang === 'undefined' ) {
				lang = 'en';
			}
			console.log( 'Loading stylesheet: ' + lang + ':' + family + ':' + page );
			mw.loader.load( '//' + mw.util.wikiUrlencode( lang + '.' + family + '.org' ) + lwgScript + '?title=' + mw.util.wikiUrlencode( page ) + '&action=raw&ctype=text/css', 'text/css' );
		}
	} );
}

$.when( $.ready, mw.loader.using( ['mediawiki.util'] ) ).then( function() {
	
	// My dashboard
	mw.util.addPortletLink(
		'p-personal',
		mw.util.getUrl( 'User:' ) + mw.util.wikiUrlencode( lwgUserName + '/dashboard' ),
		'Dashboard',
		'pt-mydashboard',
		'Show your dashboard',
		null,
		'#pt-mysubpages'
	);
	
	//mw.util.addPortletLink(portletId,href,text[,id[,tooltip[,accesskey[,nextnode]]]]);
} );

// [[User:Theopolisme/Scripts/adminhighlighter]]
window.ADMINHIGHLIGHT_EXTLINKS = true; // highlights exteral links too; needs to be at the top
importMwScript( 'User:Theopolisme/Scripts/adminhighlighter.js' );

importMwScript( 'User:Anomie/linkclassifier.js' ); // [[User:Anomie/linkclassifier.js]]
importMwStylesheet( 'User:Anomie/linkclassifier.css' ); // [[User:Anomie/linkclassifier.css]]	

importMwScript( 'User:Anomie/previewtemplatelastmod.js' ); // [[User:Anomie/previewtemplatelastmod]]

importMwScript( 'User:Andy M. Wang/pageswap.js' ); // [[User:Andy M. Wang/pageswap]]

/*******************************************************************************
* Limit scripts by namespace
*******************************************************************************/
if ( [ 0, 118 ].indexOf( lwgNamespaceNumber ) !== -1 ) { // Main and draft
	
	importMwScript( 'User:Erutuon/scripts/imageSize.js' ); // [[User:Erutuon/scripts/imageSize.js]]
	
	importMwScript( 'User:Evad37/duplinks-alt.js' ); // [[User:Evad37/duplinks-alt]]
	
	importMwScript( 'User:Qwertyytrewqqwerty/DisamAssist.js' ); // [[User:Qwertyytrewqqwerty/DisamAssist]]
	
	importMwScript( 'User:Evad37/MoveToDraft.js' ); // Backlink: [[User:Evad37/MoveToDraft]]
	window.m2d_rationale = "incubate in draftspace";
	window.m2d_notification = "Hello {{SUBST:BASEPAGENAME}}. I have moved an article you created, $1, to a [[WP:Drafts|draft]] at [[Draft:$1]] to give you more time to work on it before publishing it. When you are sure that it [[WP:NOT|belongs on Wikipedia]] and satisfies our [[WP:42|inclusion criteria]], please submit your draft for review by following the instructions at the top of the draft. ~~~~";
	
	//importMwScript( 'User:Salix alba/Citoid.js' ); // [[User:Salix alba/Citoid]]
	
} else if ( lwgNamespaceNumber === 4 ) { // Project
	
	importMwScript( 'User:Enterprisey/delsort.js' ); // [[User:Enterprisey/delsort]]
	
	importMwScript( 'User:Evad37/XFDcloser.js' ); // [[User:Evad37/XFDcloser]]
	
} else if ( lwgNamespaceNumber === 10 ) { // Template
	
	importMwScript( 'User:Frietjes/addcheckforunknownparameters.js' ); // [[User:Frietjes/addcheckforunknownparameters.js]]
	
} else if ( lwgNamespaceNumber % 2 === 1 ) { // Talk namespaces
	
	importMwScript( 'User:Jackmcbarn/editProtectedHelper.js' ); // [[User:Jackmcbarn/editProtectedHelper]]
	
}

var wikEdConfig = {};
wikEdConfig.regExTypoFix = true;
wikEdConfig.comboPresetOptions = {};
wikEdConfig.comboPresetOptions.summary = [
	'add maintenance template(s)',
	'add/update reference details',
	'copyedit',
	'{{copyvio-revdel}} request',
	'Failure to [[WP:CITE|cite]] a [[WP:RS|reliable source]]',
	'No evidence of [[WP:N|notability]]',
	'remove image(s) lacking a [[WP:FUR|fair use rationale]] for this page',
	'remove image(s) not satisifying the [[WP:NFCC|non-free content criteria]]',
	'remove [[WP:EL|external links]]',
	'remove [[WP:ELMINOFFICIAL|external links]]',
	'remove [[WP:RS|unreliable sources]]',
	'remove [[WP:RS|unreliably sourced]]',
	'remove [[WP:UNSOURCED|unsourced]]',
	'remove [[WP:BLP|unsourced personal information]]',
	'reply',
	'restore deletion notice',
	'restore maintenance template(s)',
	'revert unexplained removal of content',
];
wikEdConfig.comboPresetOptions.find = [
	'(“|”|″|«|»)',
	"(‘|’)",
	' *([|=]) *',
	'\\[http[^ ]+ ([^\\]]+)\\]',
	'\\|\\s*([^|}]+)\\s*=\\s*([|}])',
	'([^\\.,:;])<\\s*ref(\\s*[^>]*)>([^<]*)<\\s*\\/\\s*ref\\s*>([\\.,:;])',
	'\\|\\s*author(\\d*)\\s*=\\s*([^,|}]+) ([^,|} ]+)\\s*([|}])',
	'\\|\\s*author(\\d*)\\s*=\\s*([^,|}]+), ([^,|}]+)\\s*([|}])'
];
wikEdConfig.comboPresetOptions.replace = [
	'"',
	'\'',
	'$1',
	'$2',
	'$1$4<ref$2>$3</ref>',
	'|last$1=$3|first$1=$2$4',
	'|last$1=$2|first$1=$3$4'
];

// Local config for [[m:User:Hoo man/Scripts/Smart rollback]]
if( typeof( smartRollbackConfig ) === 'undefined' ) smartRollbackConfig = {};
smartRollbackConfig.editSummaries = {};
smartRollbackConfig.editSummaries[0] = 'Failure to [[WP:CITE|cite]] a [[WP:RS|reliable source]].';
smartRollbackConfig.editSummaries[1] = 'Revert unexplained removal of content.';
smartRollbackConfig.editSummaries[2] = 'Revert [[WP:SOCK|sockpuppet]].';
// </nowiki>