// ==UserScript==
// @name Autofill3
// @namespace 4chan
// @include http://boards.4chan.org/*
// ==/UserScript==
function rnd(b,l){var d=b+Math.floor(l*Math.random());return d};
function pu(x,y){x.push(y)};
function sa(x,y,z){x.setAttribute(y,z)};
function ap(x,y){x.appendChild(y)}
function id(x){return document.getElementById(x)};
function cr(x){return document.createElement(x)};
function tag(x,y){if(!y){return document.getElementsByTagName(x)}else{return x.getElementsByTagName(y)}};
function sa(x,y,z){x.setAttribute(y,z)};
function fl(e,x,y){e.elements.namedItem(x).value=y};
function chr(x){return String.fromCharCode(x)}
function rchar(){return chr(rnd(42,80))}
function fillhash(x){var s=[];for(var i=0;i<x;i++){s[i]="%"+rnd(42,80).toString(16)};return s.join("")}
if(tag('form')[0]!=null){f=document.forms[0];
//everything above this line was written by FrozenVoid for his script that generated random strings and injected them to image metadata. I left it all in tact
//fl(f,'email','noko');
fl(f,'name','INFECTED                                #tripcode');
//spaces are ignored when posting, but put the tripcode out of sight so you won't accidentally screencap it
var currentsong;
var currentlisteners;
GM_xmlhttpRequest(
{
	method: 'GET',
	url: 'http://phil.fastsh.it/shoutcast/currentsong.php',
	headers:
	{
        'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
        'Accept': 'application/atom+xml,application/xml,text/xml',
    },
	onload: function(responseDetails)
	{
		currentsong = responseDetails.responseText;
	}
}
);
GM_xmlhttpRequest
(
	{
		method: 'GET',
		url: 'http://phil.fastsh.it/shoutcast/currentlisteners.php',
		headers:
		{
			'User-agent': 'Mozilla/4.0 (compatible) Greasemonkey',
			'Accept': 'application/atom+xml,application/xml,text/xml',
		},
		onload: function(responseDetails)
		{
			if(responseDetails.responseText == "0" && currentsong != "")
			{
				fl(f,'com',"\n_______________________________________\n\u266B "+currentsong+"\nhttp://phil.fastsh.it:8000/listen.pls\nThere is nobody else listening.");
			}
			else if(responseDetails.responseText == "1" && currentsong != "")
			{
				fl(f,'com',"\n_______________________________________\n\u266B "+currentsong+"\nhttp://phil.fastsh.it:8000/listen.pls\nThere is 1 other person listening.");
			}
			else if(currentsong != "")
			{
				fl(f,'com',"\n_______________________________________\n\u266B "+currentsong+"\nhttp://phil.fastsh.it:8000/listen.pls\nThere are "+responseDetails.responseText+" other people listening.");
			}
		}
	}
);
}
