User:Casper2k3/Javascript/userwelcomebutton.js
From Wikipedia, the free encyclopedia
If a message on your talk page led you here, please be wary of who left it. Code that you insert on this page could contain malicious content capable of compromising your account. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. If this is a .js page, the code will be executed when previewing the page.
Note: After saving, you have to bypass your browser's cache to see the changes. In Internet Explorer and Firefox, hold down the Ctrl key and click the Refresh or Reload button. Opera users have to clear their caches through Tools→Preferences, see the instructions for Opera. Konqueror and Safari users can just click the Reload button.
addOnloadHook(function (){ //Add the links if (location.href.indexOf("&action=edit&issuewelcome=") == -1) return; //Are we here to issue a welcome? //Get new welcome welcomeRegExp = /&action=edit&issuewelcome=(.*)/; welcome = welcomeRegExp.exec(location.href)[1]; //Modify the form document.getElementById('wpSummary').value = "Welcome message: {{" + welcome + "}} by [[User:Casper2k3|Casper2k3]] ([[WP:RCP]])"; document.getElementById('wpTextbox1').value += "\n{{sub" + "st:" + welcome + "}} --~" + "~" + "~" + "~"; document.getElementById('editform').submit(); }); addOnloadHook(function (){ //Add the links if (location.href.indexOf("&action=edit&issuewelcomenosign=") == -1) return; //Are we here to issue a welcome? //Get new welcome welcomeRegExp = /&action=edit&issuewelcomenosign=(.*)/; welcome = welcomeRegExp.exec(location.href)[1]; //Modify the form document.getElementById('wpSummary').value = "Welcome message: {{" + welcome + "}} by [[User:Casper2k3|Casper2k3]] ([[WP:RCP]])"; document.getElementById('wpTextbox1').value += "\n{{sub" + "st:" + welcome + "}}"; document.getElementById('editform').submit(); }); addOnloadHook(function (){ //Add the links if (location.href.indexOf("&action=edit&issuewelcomenamed=") == -1) return; //Are we here to issue a welcome? //Get new welcome welcomeRegExp = /&action=edit&issuewelcomenamed=(.*)/; var urlArticle = prompt("What is article name?"); if(urlArticle == "" || urlArticle == null){ alert ("You didn't enter the name of the page! Warning cancelled.") return; } welcome = welcomeRegExp.exec(location.href)[1]; //Modify the form document.getElementById('wpSummary').value = "Welcome message: {{" + welcome + "|" + urlArticle + "}} by [[User:Casper2k3|Casper2k3]] ([[WP:RCP]])"; document.getElementById('wpTextbox1').value += "\n{{sub" + "st:" + welcome + "|" + urlArticle+ "}} --~" + "~" + "~" + "~"; document.getElementById('editform').submit(); }); var welcomeUrl = "http://en.wikipedia.org/w/index.php?title=User_talk:" + wgTitle + "&action=edit&issuewelcome="; var welcomeUrlNoSign = "http://en.wikipedia.org/w/index.php?title=User_talk:" + wgTitle + "&action=edit&issuewelcomenosign="; var welcomeUrlNamed = "http://en.wikipedia.org/w/index.php?title=User_talk:" + wgTitle + "&action=edit&issuewelcomenamed="; function userWelcomeButton(){ document.getElementById('jsArticleMessageBox').innerHTML = '<div style="background-color:yellow; -moz-border-radius:15px;"> [General]: <a href="' + welcomeUrl + 'anon"><font color="#0000FF">Anon</font></a><sup>(<a href="http://en.wikipedia.org/wiki/Template:Anon" target="_blank"><font color="#0000FF">+</font></a>)</sup> - <a href="' + welcomeUrlNoSign + 'Welcomeg"><font color="#0000FF">Standard</font></a><sup>(<a href="http://en.wikipedia.org/wiki/Template:Welcomeg" target="_blank"><font color="#0000FF">+</font></a>)</sup><br></div>'; };

