User:Mathwiz2020/usergreeter.js
From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Mozilla/Safari: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Internet Explorer: press Ctrl-F5, Opera/Konqueror: press F5.
window.userGreeter=function(data, download) { var user=Title.fromURL(download.url).userName(true); var userName=String(user); userName = userName.replace(/User:/, ""); userName = userName.replace(/_/g, " "); if(!user) { return ''; } var lk=titledWikiLink({article: user.talkPage(), action: 'edit', text: 'greet ' + userName}); var autoParams='autoedit=s#$#\n{'+'{subst:User:Mathwiz2020/Template:Welcome|'+userName+'}'+ '}%20~~'+'~~#&autosummary=Welcome!&autoclick=wpSave&autominor=true&autowatch=false'; return appendParamsToLink(lk, autoParams); } function installGreeter() { window.old_getPageInfo=window.getPageInfo; window.getPageInfo=function(data,download) { return window.userGreeter(data,download) + '<br>' + window.old_getPageInfo(data,download); } if (document.getElementsByTagName('h1')[0].innerHTML == "User creation log") { userGreeter2(); } } addOnloadHook(installGreeter); window.userGreeter2=function() { userList = document.getElementsByTagName('ul')[0].getElementsByTagName('li'); for (i=0; i<userList.length; i++) { userName = userList[i].innerHTML.replace(/.*?>/, "").replace(/<.*/, ""); userSpan = userList[i].getElementsByTagName('span')[0]; spanText = userSpan.innerHTML; spanText = spanText.substr(0, spanText.length - 2) + '> | <a href="/w/index.php?title=User_talk:'+userName+'&action=edit&autoedit=s#$#\n{'+'{subst:User:Mathwiz2020/Template:Welcome|'+userName+'}'+'}%20~~'+'~~#&autosummary=Welcome!&autoclick=wpSave&autominor=true&autowatch=false" title="Greet this user">greet</a>)'; userSpan.innerHTML = spanText; } }