User:Dave Braunschweig/welcome.js

// Adds a "Welcome user" option to the Tools menu when viewing user pages. // // References: //	https://en.wikipedia.org/wiki/Wikipedia:User_scripts/Guide //	https://doc.wikimedia.org/mediawiki-core/REL1_29/js/#!/api/mw.util

mw.loader.using("mediawiki.util", addPortletLink);

function addPortletLink { // Wait for the page to be parsed $(document).ready(function {    	// Only display on User_talk pages    	if (mw.config.get("wgCanonicalNamespace") != "User_talk") {    		return;    	}        var link = mw.util.addPortletLink( 'p-tb', '#', 'Welcome user', 'ca-welcome', 'Welcome user', null, '#t-blockip');        $(link).click( function ( event ) { event.preventDefault; welcomeUser; } );   } ); }

function welcomeUser { try { document.editform.wpTextbox1.value = "{" + "{subst:welcome}}\n" + document.editform.wpTextbox1.value; document.editform.wpSummary.value = "Welcome"; document.editform.wpSummary.focus; // document.editform.submit; }	catch (exception) { console.log(exception); } }