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>
// This was a prereq of the old warning system.
importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu');

// This was also a prereq of the old warning system.
importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css');

// The old tabbed warning system, taken from revision id 121500851.  Credits obviously still go to AzaToth.  Cheers.

// If TwinkleConfig aint exist.
if( typeof( TwinkleConfig ) == 'undefined' ) {
	TwinkleConfig = {};
}

/**
 TwinkleConfig.showSharedIPNotice may take arguments:
  true: to show shared ip notice if an IP address
  false: to not print the notice
*/
if( typeof( TwinkleConfig.showSharedIPNotice ) == 'undefined' ) {
	TwinkleConfig.showSharedIPNotice = true;
}

/**
 TwinkleConfig.markWarningsAsMinor (boolean)
 Defines if a warning should be marked as minor, if false, default is applied as per preference.
*/
if( typeof( TwinkleConfig.markWarningsAsMinor ) == 'undefined' ) {
	TwinkleConfig.markWarningsAsMinor = true;
}

/**
TwinkleConfig.summaryAd (string)
If ad should be added or not to summary, default [[WP:TWINKLE|TWINKLE]]
*/
if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) {
	TwinkleConfig.summaryAd = " using [[WP:TWINKLE|TW]]";
}

function blockTagAdd( tag, summary ) {
	var reason = null;
	var notice = null;
	var duration = null;

	if( [ 'uw-sblock', 'uw-vblock', 'uw-dblock' ].indexOf( tag ) != -1 ) {
		duration = prompt( 'What is the duration of the block? (blank, min or temp/tmp for temporary block, *, indef or max for indefinite block)' );
		if( /te?mp|^\s*$|min/.exec( duration ) ) {
			notice = '{{subst:' + tag + '|subst=subst:}} ~~' + '~~';
		} else if( /indef|\*|max/.exec( duration ) ) {
			notice = '{{subst:' + tag + '|indef=yes|subst=subst:}} ~~' + '~~';
		} else {
			notice = '{{subst:' + tag + '|time=' + duration + '|subst=subst:}} ~~' + '~~';
		}
	} else {
		if( tag != 'uw-block3') {
			duration = prompt( 'What duration is the block for?' );
		}

		reason = prompt( 'Reason for block?' );

		notice = '{{subst:' + tag + ( duration ? '|time=' + duration : '' ) + ( reason ? '|reason=' + reason : '' ) + '|subst=subst:}} ~~' + '~~';
	}

	// BEGIN WikiEd -> wpTextbox1
	if (typeof(wikEdUseWikEd) != 'undefined') {
		if (wikEdUseWikEd == true) {
			WikEdUpdateTextarea();
		}
	}
	// END
	var textbox = document.getElementById( 'wpTextbox1' );
	textbox.value += "\n" + notice;
	// BEGIN wpTextbox1 -> WikiEd
	if (typeof(wikEdUseWikEd) != 'undefined') {
		if (wikEdUseWikEd == true) {
			WikEdUpdateFrame();
		}
	}
	// END

	if( TwinkleConfig.markWarningsAsMinor ) {
		document.getElementById( 'wpMinoredit' ).checked = true;
	}
	document.getElementById( 'wpSummary' ).value = summary + '.' + TwinkleConfig.summaryAd;
}

function tagadd( tag , summary) {
	var article;

	if( QueryString.exists( 'vanarticle' ) ) {
		article = decodeURI(QueryString.get( 'vanarticle' )).replace( /^(Image|Category):/i, ':$1:' );
	} else {
		article = prompt('Which article?').replace( /^(Image|Category):/i, ':$1:' );
	}

	var date = new Date();
	var notice = "";
	var header = "";

	var headerRe = new RegExp( "^===\\s*" + date.getUTCMonthName() + "\\s+" + date.getUTCFullYear() + "\\s*===", 'm' );
	var textbox = document.getElementById( 'wpTextbox1' );

	if ( textbox.value.length > 0 ) {
		textbox.value += '\n';
	}
	if( !headerRe.exec( textbox.value ) ) {
		header += "=== " + date.getUTCMonthName() + " " + date.getUTCFullYear() + " ===\n";
	}

	notice += header;
	notice += "{{subst:" + tag + ( article ? '|' + article + '|subst=subst:' : '' ) + "}} ~~" + "~~"; // subst=subst: hack only on article given as per MW bug :(
	if ( TwinkleConfig.showSharedIPNotice && isIPAddress( wgTitle ) ) {
		switch( QueryString.get( 'type' ) ) {
			case 'vand':
			notice +=  "\n:''If this is a shared [[IP address]], and you didn't make any [[Wikipedia:vandalism|unconstructive]] edits, consider [[Wikipedia:Why create an account?|creating an account]] for yourself so you can avoid further irrelevant warnings.'' ";
			break;
			default:
			notice +=  "\n:''If this is a shared [[IP address]], and you didn't make the edit, consider [[Wikipedia:Why create an account?|creating an account]] for yourself so you can avoid further irrelevant notices.'' ";
			break;
		}
	}

	// BEGIN WikiEd -> wpTextbox1
	if (typeof(wikEdUseWikEd) != 'undefined') {
		if (wikEdUseWikEd == true) {
			WikEdUpdateTextarea();
		}
	}
	// END


	textbox.value += "\n" + notice;
	// BEGIN wpTextbox1 -> WikiEd
	if (typeof(wikEdUseWikEd) != 'undefined') {
		if (wikEdUseWikEd == true) {
			WikEdUpdateFrame();
		}
	}
	// END	

	document.getElementById( 'wpSummary' ).value = summary + ( article ? ' on [[' + article + ']]'  : '' ) + '.' + TwinkleConfig.summaryAd;
	if( TwinkleConfig.markWarningsAsMinor ) {
		document.getElementById( 'wpMinoredit' ).checked = true;
	}
}

//Quick warning tabs
function add_warn_tabs() 
{ 
	var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0];

	if ( wgNamespaceNumber == 3 && ( QueryString.equals( 'action', 'edit' ) || QueryString.equals( 'action', 'submit' ) ) ) {

		addlimenu(tabs, '[1]', 'generalnotefunc');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-vandalism1", "General note: Vandalism")', 'Vandalism', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-delete1", "General note: Page blanking, removal")', 'Page blanking, removal', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-test1", "General note: Tests")', 'Editing tests', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-upv1", "General note: Userpage vandalism")', 'Userpage vandalism', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-tpv1", "General note: Talkpage vandalism")', 'Talkpage vandalism', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-error1", "General note: Factual errors")', 'Factual errors', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-mos1", "General note: Manual of style")', 'Manual of style', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-agf1", "General note: Assume good faith")', 'AGF', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-npa1", "General note: Personal attack")', 'Personal attack', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-defamatory1", "General note: Defamatory")', 'Defamation', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-joke1", "General note: Improper humour")', 'Improper humour', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-biog1", "General note: Negative bio")', 'Negative bio', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-npov1", "General note: NPOV")', 'NPOV', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-spam1", "General note: Spam")', 'Spam', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-copyright1", "General note: Copyright")', 'Copyright', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-creation1", "General note: Creation")', 'Creation', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-image1", "General note: Image")', 'Image', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-notcensored1", "General note: Censorship")', 'Censorship', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-unsourced1", "General note: Unsourced")', 'Unsourced', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-move1", "General note: Moves")', 'Moves', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-afd1", "General note: Removing {{"+"afd}} templates")', 'Afd', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-speedy1", "General note: Removing {{"+"speedy deletion}} templates")', 'Speedy', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-chat1", "General note: Inappropriate talk page [[WP:TALK#Behavior_that_is_unacceptable|usage]]")', 'Chat', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-own1", "General note: Ownership of articles")', 'Ownership', '');
		mw.util.addPortletLink('generalnotefunc', 'javascript:tagadd("uw-maintenance1", "General note: Removal of maintenance templates")', 'Maintenance templates', '');

		addlimenu(tabs, '[2]', 'cautionfunc');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-vandalism2", "Caution: Vandalism")', 'Vandalism', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-delete2", "Caution: Page blanking, removal")', 'Page blanking, removal', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-test2", "Caution: Tests")', 'Editing tests', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-upv2", "Caution: Userpage vandalism")', 'Userpage vandalism', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-tpv2", "Caution: Talkpage vandalism")', 'Talkpage vandalism', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-error2", "Caution: Factual errors")', 'Factual errors', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-mos2", "Caution: Manual of style")', 'Manual of style', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-agf2", "Caution: Assume good faith")', 'AGF', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-npa2", "Caution: Personal attack")', 'Personal attack', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-defamatory2", "Caution: Defamatory")', 'Defamation', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-joke2", "Caution: Improper humour")', 'Improper humour', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-biog2", "Caution: Negative bio")', 'Negative bio', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-npov2", "Caution: NPOV")', 'NPOV', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-spam2", "Caution: Spam")', 'Spam', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-copyright2", "Caution: Copyright")', 'Copyright', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-creation2", "Caution: Creation")', 'Creation', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-image2", "Caution: Image")', 'Image', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-notcensored2", "Caution: Censorship")', 'Censorship', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-unsourced2", "Caution: Unsourced")', 'Unsourced', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-move2", "Caution: Moves")', 'Moves', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-afd2", "Caution: Removing {{"+"afd}} templates")', 'Afd', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-speedy2", "Caution: Removing {{"+"speedy deletion}} templates")', 'Speedy', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-chat2", "Caution: Inappropriate talk page [[WP:TALK#Behavior_that_is_unacceptable|usage]]")', 'Chat', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-own2", "Caution: Ownership of articles")', 'Ownership', '');
		mw.util.addPortletLink('cautionfunc', 'javascript:tagadd("uw-maintenance2", "Caution: Removal of maintenance templates")', 'Maintenance templates', '');

		addlimenu(tabs, '[3]', 'warningfunc');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-vandalism3", "Warning: Vandalism")', 'Vandalism', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-delete3", "Warning: Page blanking, removal")', 'Page blanking, removal', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-test3", "Warning: Tests")', 'Editing tests', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-upv3", "Warning: Userpage vandalism")', 'Userpage vandalism', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-tpv3", "Warning: Talkpage vandalism")', 'Talkpage vandalism', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-error3", "Warning: Factual errors")', 'Factual errors', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-mos3", "Warning: Manual of style")', 'Manual of style', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-agf3", "Warning: Assume good faith")', 'AGF', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-npa3", "Warning: Personal attack")', 'Personal attack', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-defamatory3", "Warning: Defamatory")', 'Defamation', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-joke3", "Warning: Improper humour")', 'Improper humour', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-biog3", "Warning: Negative bio")', 'Negative bio', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-npov3", "Warning: NPOV")', 'NPOV', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-spam3", "Warning: Spam")', 'Spam', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-copyright3", "Warning: Copyright")', 'Copyright', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-creation3", "Warning: Creation")', 'Creation', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-image3", "Warning: Image")', 'Image', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-notcensored3", "Warning: Censorship")', 'Censorship', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-unsourced3", "Warning: Unsourced")', 'Unsourced', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-move3", "Warning: Moves")', 'Moves', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-afd3", "Warning: Removing {{"+"afd}} templates")', 'Afd', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-speedy3", "Warning: Removing {{"+"speedy deletion}} templates")', 'Speedy', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-chat3", "Warning: Inappropriate talk page [[WP:TALK#Behavior_that_is_unacceptable|usage]]")', 'Chat', '');
		mw.util.addPortletLink('warningfunc', 'javascript:tagadd("uw-own3", "Warning: Ownership of articles")', 'Ownership', '');

		addlimenu(tabs, '[4]', 'fwarningfunc');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-vandalism4", "Final warning: Vandalism")', 'Vandalism', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-vandalism4im", "Only warning: Vandalism")', 'Vandalism (im)', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-delete4", "Final warning: Page blanking, removal")', 'Page blanking, removal', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-delete4im", "Only warning: Page blanking, removal")', 'Page blanking, removal (im)', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-npa4", "Final warning: Personal attack")', 'Personal attack', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-npa4im", "Only warning: Personal attack")', 'Personal attack (im)', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-defamatory4", "Final warning: Defamatory")', 'Defamation', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-defamatory4im", "Only warning: Defamatory")', 'Defamation (im)', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-joke4", "Final warning: Improper humour")', 'Improper humour', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-biog4", "Final warning: Negative bio")', 'Negative bio', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-npov4", "Final warning: NPOV")', 'NPOV', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-spam4", "Final warning: Spam")', 'Spam', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-spam4im", "Only warning: Spam")', 'Spam (im)', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-copyright4", "Final warning: Copyright")', 'Copyright', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-creation4", "Final warning: Creation")', 'Creation', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-image4", "Final warning: Image")', 'Image', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-image4im", "Only warning: Image")', 'Image (im)', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-move4", "Final warning: Moves")', 'Moves', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-afd4", "Final warning: Removing {{"+"afd}} templates")', 'Afd', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-speedy4", "Final warning: Removing {{"+"speedy deletion}} templates")', 'Speedy', '');
		mw.util.addPortletLink('fwarningfunc', 'javascript:tagadd("uw-chat4", "Final warning: Inappropriate talk page [[WP:TALK#Behavior_that_is_unacceptable|usage]]")', 'Chat', '');

		addlimenu(tabs, '[S]', 'singlefunc');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-bv", "Blatant vandalism")', 'Blatant vandal', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-3rr", "in danger of violating the [[WP:3RR|three-revert rule]]")', '3RR', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-hoax", "Please do not create hoaxes")', 'Hoax', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-legal", "Legal threats are not tolerated")', 'Legal threats', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-longterm", "Long term pattern of abuse")', 'Longterm', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-racism", "Racism towards users")', 'Racism', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-pinfo", "Posting parsonal info about other is prohibited")', 'Personal info', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-selfrevert", "Reverting self tests")', 'Selfrevert', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-autobiography", "Autobiographies violate several guidelines, and will probably be deleted.")', 'Autobiography', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-warn", "Please warn vandals after reverting their edits")', 'Warning vandals', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-aiv", "Vandals must have a final warning before being blocked")', 'Bad AIV report', '');
		mw.util.addPortletLink('singlefunc', 'javascript:tagadd("uw-english", "Please communicate only in English")', '*English', '');

		if( userIsInGroup( 'sysop' ) ) {
			addlimenu(tabs, '[B]', 'blockfunc');
			mw.util.addPortletLink('blockfunc', 'javascript:blockTagAdd("uw-block1", "You have been blocked")', 'Level 1', '');
			mw.util.addPortletLink('blockfunc', 'javascript:blockTagAdd("uw-block2", "You have been blocked")', 'Level 2', '');
			mw.util.addPortletLink('blockfunc', 'javascript:blockTagAdd("uw-block3", "You have been indefinitely blocked")', 'Level 3', '');
			mw.util.addPortletLink('blockfunc', 'javascript:blockTagAdd("uw-sblock", "You have been blocked for spam")', 'Spam', '');
			mw.util.addPortletLink('blockfunc', 'javascript:blockTagAdd("uw-vblock", "You have been blocked for persistent vandalism")', 'Vandalism', '');
			mw.util.addPortletLink('blockfunc', 'javascript:blockTagAdd("uw-dblock", "You have been blocked for continued deletion of material")', 'Delete', '');
		}
	}
}
$(add_warn_tabs);
//</nowiki>