User:Example/statusupdate.js

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.
if (mw.config.get('wgPageName')=='User:'+mw.config.get('wgUserName') || mw.config.get('wgPageName')=='User_talk:'+mw.config.get('wgUserName')) {
$(document).ready(function() {
	if (typeof hideStatus == 'undefined') { hideStatus = false; };
	if ($('#user-status')) {
		if (hideStatus) { $('#user-status').attr('style','visibility:visible'); };
		$('#user-status span').attr('style','cursor:pointer');
		$('#user-status span').click(function() {
			var statusText = $(this).html();
			var summ = 'updating status';
			var token;

			$.ajax({
				url: '/w/api.php?action=query&prop=info&intoken=edit&titles=Main_page&format=json',
				success: function(data) { token = data.query.pages[Object.keys(data.query.pages)].edittoken.replace(/\+\\$/g,'%2B%5C'); },
				dataType: 'json',
				async: false
			});

			$.ajax({
				type: 'POST',
				url: '/w/api.php?action=edit&title=User:'+wgUserName+'/Status&summary='+summ+'&minor=1&recreate=1&text='+statusText+'&token='+token,
				async: false
			});

			window.location.reload();
		});
	};
});
};