Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/**
 * TemplateScript adds configurable templates and scripts to the sidebar, and adds an example regex editor.
 * @see https://meta.wikimedia.org/wiki/TemplateScript
 * @update-token [[File:Pathoschild/templatescript.js]]
 */
// <nowiki>
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
	/**
	 * Mark a local bot request as closed.
	 * @param {object} editor The page editor.
	 * @param {string} message The message to insert as a response.
	 * @param {string} summary The edit summary to insert.
	 */
	function closeBotRequest(editor, message, summary) {
		editor
			.replace(/^(=+)\s+(.+?)\s+(\1).+/, '$1$2$1') // normalise header
			.replace(/^(.+=)\n([\s\S]+)$/, '$1\n<div style="background:#E3F9DF; padding:0 10px; border:1px solid #AAA;">\n$2\n: ' + message + ' --~~~~\n</div>') // place formatted box & message
			.appendEditSummary(summary);
	}
	
	pathoschild.TemplateScript.add([
		// create bot policy redirect
		{
			name: 'BPI redirect',
			script: function(editor) {
				var target = editor.get();
				editor
					.set('#REDIRECT [[' + target + ']]')
					.setEditSummary('redirected to [[' + target + '|bot request page]] for [[m:bot policy|standard bot policy]]');
			}
		},
		
		// insert bot policy text
		{
			name: 'BPI text',
			script: function(editor) {
				editor
					.prepend(
						"* '''" + mw.config.get('wgContentLanguage') + ":''' {{int:please-translate}}.\n"
						+ "* '''en:''' Requests for the [[m:bot|bot]] flag should be made on this page. This wiki uses the [[m:bot policy|standard bot policy]], and allows [[m:bot policy#Global_bots|global bots]] and [[m:bot policy#Automatic_approval|automatic approval of certain types of bots]]. Other bots should apply below, and then [[m:Steward requests/Bot status|request access]] from a steward if there is no objection.\n"
						+ "* '''en:''' Requests for the [[m:bot|bot]] flag should be made on this page. This wiki uses the [[m:bot policy|standard bot policy]], and allows [[m:bot policy#Global_bots|global bots]] and [[m:bot policy#Automatic_approval|automatic approval of certain types of bots]]. Other bots should apply below.\n\n"
					)
					.setEditSummary('implemented [[m:bot policy|standard bot policy]]');
			}
		},
		
		// insert bot policy proposal
		{
			name: 'BPI proposal',
			script: function(editor) {
				editor
					.replace(/[\s\n]*$/, '')
					.append(
						 '\n\n==Bot policy==\n'
						+ '{{int:hello}}\n\nTo facilitate [[m:Special:MyLanguage/Stewards|steward]] granting of bot access, I suggest implementing the [[m:Special:MyLanguage/Bot policy|standard bot policy]] on this wiki. In particular, this policy allows stewards to automatically flag known interlanguage linking bots (if this page says that is acceptable). The policy also enables [[m:Bot policy#Global_bots|global bots]] on this wiki (if this page says that is acceptable), which are trusted bots that will be given bot access on every wiki that allows global bots.\n\n'
						+ 'This policy makes bot access requesting much easier for local users, operators, and stewards. To implement it we only need to create a redirect to this page (or to the dedicated page the community uses to handle bot approvals) from [[Project:Bot policy]], and add a line at the top noting that it is used here. Please read the text at [[m:Bot policy]] before commenting. If you object, please say so; I hope to implement it soon if there is no objection, since it is particularly written to streamline bot requests on wikis with little or no community interested in bot access requests.\n\n'
						+ '{{int:thank-you}}\n\n--~~~~'
					)
					.setEditSummary('+ /* Bot policy */');
			}
		},
		
		// mark local bot request as already done
		{
			name: 'BR: already done',
			script: function(editor) {
				var botName = editor.get().replace(/^.+\[\[[^:]+:([^\|\]]+)[\s\S]+$/, '$1');
				var message = 'Already [{{fullurl:m:Special:Log|page=User:' + botName + '@' + mw.config.get('wgDBname') + '}} done].';
				
				closeBotRequest(editor, message, 're: already done');
			}
		},
		
		// mark local bot request as not done
		{
			name: 'BR: not done, global bot',
			script: function(editor) {
				closeBotRequest(editor, 'Not done; a local bot flag is no longer needed. This is a [[m:bot policy|global bot]], and this wiki recently enabled global bots.', 're: not done, global bot');
			}
		},
		
		// mark local bot request as done
		{
			name: 'BR: done',
			script: function(editor) {
				closeBotRequest(editor, 'Done.', 're: done');
			}
		}
	]);
});
// </nowiki>