Chú ý: Sau khi lưu thay đổi trang, bạn phải xóa bộ nhớ đệm của trình duyệt để nhìn thấy các thay đổi. Google Chrome, Firefox, Internet ExplorerSafari: Giữ phím ⇧ Shift và nhấn nút Reload/Tải lại trên thanh công cụ của trình duyệt. Để biết chi tiết và hướng dẫn cho các trình duyệt khác, xem Trợ giúp:Xóa bộ nhớ đệm.

// Install with:
// <code><nowiki>		{{subst:Iusc|User:DannyS712/draft re cat.js}}																</nowiki></code>
// or with
// <code><nowiki>		importScript( 'User:DannyS712/draft re cat.js' ); // Backlink: [[User:DannyS712/draft re cat.js]]			</nowiki></code> 
//
// If forking this script, please note my contributions / give me credit
$(() => {
const DraftReCat = {};
window.DraftReCat = DraftReCat;
DraftReCat.config = {
	name: '[[w:en:User:DannyS712/Draft no cat|Draft no cat]]',
	version: 1.1,
	debug: false
};

DraftReCat.summary = 'Khôi phục việc xếp thể loại (sử dụng ' + DraftReCat.config.name + " v" + DraftReCat.config.version + ").";
	
DraftReCat.run = function () {
	if ( DraftReCat.config.debug ) {
		console.log ( DraftReCat.summary );
	}
	
	var api = new mw.Api();
	api.get( {
		action: 'query',
		titles: mw.config.get( 'wgPageName' ),
		prop: 'revisions',
		rvprop: 'content',
		rvslots: 'main',
		formatversion: 2
	} ).done(
		function ( response ) {
			console.log( response );
			var text = response.query.pages[0].revisions[0].slots.main.content;
			var newText = text
				.replace( /\[\[:Thể loại/gi, '\[\[Thể loại' ); // Replace links with categorization

			api.postWithEditToken( {
				action: 'edit',
				title: mw.config.get( 'wgPageName' ),
				text: newText,
				summary: DraftReCat.summary
			} ).done(
				function() {
					location.reload();
				}
			);
		}
	);
};

});

$( document ).ready( () => {
	mw.loader.using(
		[ 'mediawiki.util' ],
		function () {
			var link = mw.util.addPortletLink( 'p-cactions', '#', 'DRC', 'ca-drc', 'Draft re cats'); 
			$( link ).click( function ( event ) {
				event.preventDefault();
				mw.loader.using( 'mediawiki.api', window.DraftReCat.run );
			} );
		}
	);
} );