User:MPGuy2824/MoveToDraft.js

/******************************************************************************
 MoveToDraft
-------------
Version 2.5.8
-------------
A script to move unsourced articles to draft space, including cleanup and author notification.
- Moves page to draftspace
- Checks if any files used are non-free
- Checks if any redirects pointed to the page
- Comments out non-free files, turn categories into links, add afc draft template, add redirects
- Adds notification message on author talk page
- Updates talk page banners
- Logs draftification in user subpage

 derived from https://en.wikipedia.org/wiki/User:Evad37/MoveToDraft.js
******************************************************************************/
/* jshint laxbreak: true, undef: true, maxerr:999 */
/* globals console, window, document, $, mw */
// <nowiki>

// Script info
var mtd = {
	config: {
		script: {
			// For window header
			location: "User:MPGuy2824/MoveToDraft",
			version: "2.5.8"
		}
	}
},
	API;

$.when(
	// Resource loader modules
	mw.loader.using( [ 'mediawiki.util', 'mediawiki.api', 'mediawiki.Title' ] ),
	// Page ready
	$.ready
).then( function() {
/* ========== Config ======================================================= */
	// MediaWiki configuration values
mtd.config.mw = mw.config.get( [
		"wgArticleId",
		"wgCurRevisionId",
		"wgPageName",
		"wgUserGroups",
		"wgUserName",
		"wgMonthNames",
		"wgNamespaceNumber",
		"wgTitle",
		"wgArticlePath",
		"wgIsMainPage",
		"wgIsRedirect"
	]
);

/* ========== API ========================================================== */
API = new mw.Api( {
	ajax: {
		headers: { 
			"Api-User-Agent": "MoveToDraft/" + mtd.config.script.version + 
				" ( https://en.wikipedia.org/wiki/User:MPGuy2824/MoveToDraft )"
		}
	}
} );

var dynamicallyLoadScript = function( url ) {
	let loadScript = document.createElement( 'script' );
	loadScript.src = url + '?action=raw&ctype=text/javascript';
	document.head.appendChild( loadScript );
};

/* ========== Setup ============================================================================= */

// Only operate in article namespace
if( mtd.config.mw.wgNamespaceNumber !== 0 ) {
	return;
}

// Don't draftify MainPage
if( mtd.config.mw.wgIsMainPage === true ) {
	return;
}

// Only operate for existing pages
if ( mtd.config.mw.wgCurRevisionId === 0 ) {
	return;
}

// Only for articles
if ( mtd.config.mw.wgIsRedirect === true ) {
	return;
}

dynamicallyLoadScript(
	mtd.config.mw.wgArticlePath.replace( '$1', 'User:MPGuy2824/MoveToDraft/core.js' )
);

});
// </nowiki>

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.