User:Syndrome/Welcum.js

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes.

  • Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
  • Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
  • Opera, Konqueror and Safari users can just click the Reload button.
  • Chrome: press Ctrl+F5 or Shift+F5
// <pre><nowiki>

function replaceTalk() {
   var d = document.links;
   for ( var l in d ) {
      if ( d[l].className == 'new' && d[l].href.indexOf('User_talk') >= 0 && d[l-1].title.indexOf('User:') == 0) {
         d[l-1].href = d[l].href + '&autoWelcome=2';
         d[l-1].className = 'limegreen';

         d[l].href += '&autoWelcome=1';
         d[l].className = 'limegreen';

      }
      else if ( d[l].id == 'pt-userpage' ) break;
   }
}
function doAutoWelcome() {
    carryon = queryString('autoWelcome');
    if(carryon == null)
        return;
    if(carryon == 1) {
        if(document.getElementById('wpTextbox1').value != '') {
            alert('looks like someone beat you to it');
            return;
        }
        document.getElementById('wpTextbox1').value = '{{subst:User:Syndrome/Welcome}} ~~~~';
        document.getElementById('wpSummary').value = 'Welcome to Wikipedia!';
        document.getElementById('editform').submit();
    }
    if(carryon == 2) {
        if(document.getElementById('wpTextbox1').value != '') {
          alert('looks like someone beat you to it');
          return;
      }
      document.getElementById('wpTextbox1').value = '{{subst:Oh Dear}} ~~~~';
      document.getElementById('wpSummary').value = 'Oh dear.';
      document.getElementById('editform').submit();
    }
}

function autoTalkLoad() {
    replaceTalk();
    doAutoWelcome();
}
function queryString(p) {
	var re = RegExp('[&?]' + p + '=([^&]*)');
  
	var matches;
  
	if (matches = re.exec(document.location)) {
		try { 
			return decodeURI(matches[1]);
		} catch (e) {
		}
	}
  
	return null;
};
YAHOO.util.Event.onDOMReady(autoTalkLoad);

//</nowiki></pre>