User:Wolfman~enwikisource/welcome.js

var url=location.href; var welcomer;

function Welcomer { this.users = document.body.getElementsByTagName('ul')[0].getElementsByTagName('li'); this.child = window.open; this.i = 0; this.next = next; }

function next { var flg = 1; while (flg && this.i < this.users.length) { var talk_url = this.users[this.i].getElementsByTagName('a')[1].href; if (talk_url.search('&action=edit') != -1 && talk_url.search('User_talk:') != -1) { flg = 0; this.child.location.replace(talk_url+'&autowelcome&tag=true');} this.i++;} if (flg) {this.child.close; window.location.replace('http://en.wikisource.org/wiki/Special:Log/newusers'); return;} }

function welcome_tab(nxt_url,name) { var na = document.createElement('a'); na.setAttribute('href', nxt_url); na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); li.appendChild(na); var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; tabs.appendChild(li); }

function hack {opener.welcomer.next;}

function welcome { var form=document.editform; var box=form.wpTextbox1 var txt=box.value; var msg='\{\{' + 'welcome' + '\}\}\n\n'; box.value = msg+txt; form.wpSummary.value = 'welcome to wikisource'; window.onunload=hack; form.submit; }

function in_url(string) { return (url.search(string) != -1); }

function welcome_hooks { if (in_url('Special:Log') && in_url('newusers')) { if (!in_url('&tag=true')) {welcome_tab(url+'?&tag=true','welcome everyone')} else                     {welcomer = new Welcomer; welcomer.next;} return;} if (in_url('&autowelcome')) {welcome; return;} }

welcome_hooks;