ব্যবহারকারী:Tanbiruzzaman/খসড়ায় স্থানান্তর.js

লক্ষ্য করুন: প্রকাশ করার পর, পরিবর্তনগুলো দেখতে আপনাকে আপনার ব্রাউজারের ক্যাশে পরিষ্কার করার প্রয়োজন হতে পারে।

  • ফায়ারফক্স / সাফারি: পুনরায় লোড-এ ক্লিক করার সময় শিফট টিপে ধরে রাখুন, অথবা হয় Ctrl-F5 বা Ctrl-R টিপুন (ম্যাকে ⌘-R টিপুন)
  • গুগল ক্রোম: Ctrl-Shift-R (ম্যাকে ⌘-Shift-R) টিপুন
  • ইন্টারনেট এক্সপ্লোরার / এজ: Ctrl ধরে রাখা অবস্থায় Refresh-এ ক্লিক করুন, অথবা Ctrl-F5 টিপুন
  • অপেরা: Ctrl-F5 টিপুন।
/******************************************************************************
 খসড়ায় স্থানান্তর
-------------
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 config = {
	script: {
		// For window header
		location: "User:Tanbiruzzaman/খসড়ায় স্থানান্তর",
		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
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/" + config.script.version + 
				" ( https://bn.wikipedia.org/wiki/User:Tanbiruzzaman/খসড়ায় স্থানান্তর )"
		}
	}
} );

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

/* ========== Setup ============================================================================= */
// Access draftifications using Special:Draftify_log/USER_NAME
var isDraftifyLogPage = config.mw.wgPageName.indexOf( "Special:Draftify_log" ) === 0;
var isUserPage = config.mw.wgNamespaceNumber === 2 || config.mw.wgNamespaceNumber === 3;
if ( isDraftifyLogPage ) {
	dynamicallyLoadScript(
		config.mw.wgArticlePath.replace( '$1', 'User:Tanbiruzzaman/খসড়ায় স্থানান্তর/draftifyLog.js' )
	);
	return;
} else if ( isUserPage ) {
	var user = config.mw.wgTitle.split( '/' )[ 0 ];
	var url = mw.util.getUrl( "Special:Draftify_log/" + user );
	mw.util.addPortletLink( ( window.m2d_portlet || 'p-cactions' ), url, 'Draftify log', 'ca-m2dlog', null, null, "#ca-move" );
	return;
}

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

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

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

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

dynamicallyLoadScript(
	config.mw.wgArticlePath.replace( '$1', 'User:Tanbiruzzaman/খসড়ায় স্থানান্তর/core.js' )
);

});
// </nowiki>