User:小躍/common.js

From Meta, a Wikimedia project coordination wiki

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.
$.ajax('//tools-static.wmflabs.org/meta/scripts/pathoschild.templatescript.js', { dataType:'script', cache:true }).then(function() {
	if(mw.config.get('wgPageName').match(/Stewards\/Confirm\/[2][0-9][0-9][0-9]\//)&&$.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1){
		pathoschild.TemplateScript.add([
		{
			name:'Vote:Keep',
			script: function(editor) {
				if($('#wpTextbox1').val().match('Place votes ABOVE this line')){
					editor.replace(new RegExp('<!--Place votes ABOVE','i'),'*{{'+'k'+'}}--~~'+'~~\n<!--Place votes ABOVE');	
				}else{
					editor.replace(new RegExp('<section end','i'),'*{{'+'k'+'}}--~~'+'~~\n<section end');
				}
				
			editor
				.appendEditSummary('Vote Keep using Pathoschild.TemplateScript')
				.options({ minor: true})
				.clickDiff();
			}
		},
		{
			name:'Say:Thanks',
			script: function(editor) {
				if($('#wpTextbox1').val().match('Place votes ABOVE this line')){
					editor.replace(new RegExp('<!--Place votes ABOVE','i'),'*Thanks for your Stewards work. --~~'+'~~\n<!--Place votes ABOVE');	
				}else{
					editor.replace(new RegExp('<section end','i'),'*Thanks for your Stewards work. --~~'+'~~\n<section end');
				}
			editor
				.appendEditSummary('Say Thanks using Pathoschild.TemplateScript')
				.options({ minor: true})
				.clickDiff();
			}
		}
		]);
	}
});//PT. end