2008-07-17

犯行予告ジェネレータ

サーバーサイドでマジメに作ったら逮捕されるんだろうか…?けーさつこわいから悪用とかしないでね><

ところで2chのどっかの板の名前欄って人名と地名がランダム表示されるけど、どうやってリストを作成してるんだろ?

<html><head><title>反抗予告ジェネレータ</title><script type="text/javascript"><!--

var safe_mode = 1;
var date, place, object, action;

date = get_date();
object = get_object();
action = get_action();
httpRequest("http://ja.wikipedia.org/wiki/%E6%97%A5%E6%9C%AC%E3%81%AE%E5%A4%A7%E5%AD%A6%E4%B8%80%E8%A6%A7");

function get_date() {
	var now = new Date();
	now.setTime(now.getTime() + Math.floor(Math.random()*1000*60*60*24*30));

	if (safe_mode != 0) { now.setTime(now.getTime() + 1000*60*60*24*(365*3+366)/4*100); }

	return now.getYear()+"年"+(now.getMonth()+1)+"月"+now.getDate()+"日"+now.getHours()+"時"+now.getMinutes()+"分"+now.getSeconds()+"秒";
}

function get_object() {
	var b = ["小女子", "増田", "ひろゆき", "ぬこ"];
	return b[Math.floor(Math.random()*b.length)];
}

function get_action() {
	var b = ["投", "SATSUGAI", "なでなで", "もふもふ"];
	return b[Math.floor(Math.random()*b.length)];
}

function httpRequest(target_url) {
	try {
		if(window.XMLHttpRequest) {	httpObj = new XMLHttpRequest(); }
		else if(window.ActiveXObject) {	httpObj = new ActiveXObject("Microsoft.XMLHTTP"); }
		else { return; }
	} catch(e) { return; }

	httpObj.open("GET", target_url, true);
	httpObj.onreadystatechange = DataRead;
	httpObj.send("");

	return;
}

function DataRead() {
	if (httpObj.readyState == 4 &amp;&amp; httpObj.status == 200) {

		var res = httpObj.responseText;
		var b = new Array();
		b = res.match(/>([亜-熙]+)大学/g);
		place = b[Math.floor(Math.random()*b.length-1)].replace(">","");

		if (safe_mode != 0) { place = place.replace("大学", "○○"); }

		document.body.innerText = date+"に"+place+"あたりで"+object+"を"+action+"します…!";
	}
}

// --></script></head><body style="color:red; background-color:black; font-size:30px; text-align:center;"></body></html>

記事への反応(ブックマークコメント)

ログイン ユーザー登録
ようこそ ゲスト さん