User:Casper2k3/Javascript/userwelcomebutton.js
Appearance
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
Documentation for this user script can be added at User:Casper2k3/Javascript/userwelcomebutton. |
//<nowiki>
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>';
};
//</nowiki>