User:MrN9000/Welcum.js
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() {
alinks = document.getElementsByTagName('a');
for(i = 0; i < alinks.length; i++) {
prevsib = alinks[i].previousSibling;
if(prevsib == null)
continue;
while(prevsib.nodeType != 1) {
prevsib = prevsib.previousSibling;
if(prevsib == null) {
prevsib = alinks[i].previousSibling;
break;
}
}
if(alinks[i].getAttribute('class') != 'new' || alinks[i].innerHTML != 'Talk' || prevsib.getAttribute('title').indexOf('User:') != 0)
continue;
alinks[i].setAttribute('href', alinks[i].getAttribute('href') + '&autoWelcome=true');
alinks[i].setAttribute('class', 'limegreen');
}
}
function doAutoWelcome() {
carryon = queryString('autoWelcome');
if(carryon == null)
return;
if(document.getElementById('wpTextbox1').value != '') {
alert('looks like someone beat you to it');
return;
}
document.getElementById('wpTextbox1').value = '{{subst:User:MrN9000/Welcome}} ~~~';
document.getElementById('wpSummary').value = 'Welcome to Uncyclopedia!';
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>