<html>

<head>
<script>


aryCheck = new Array();
aryItemId = new Array();
aryName = new Array();
aryLevel = new Array();
aryIni = new Array();
aryVit = new Array();
aryDex = new Array();
aryPsy = new Array();
aryType = new Array();
aryAbl = new Array();
aryExt = new Array();
aryEqu = new Array();
aryImp = new Array();

maxid = 0;

function openPage(){

	cgimode = document.fm.cgimode.value;
	cgilines = document.fm.cgilines.value;
	tgtWin = window.open("http://t-walker.jp/mugefan/status/status_itm.cgi?order=lv&mode=" + cgimode + "&lines=" + cgilines,"tgtWin")

}


function analyzePage(){

	aryBuf = new Array()

	if (typeof(tgtWin) == 'undefined'){
		alert('対象ウィンドウが開かれていません。\nウィンドウを開きます。');
		openPage();
		alert('ウィンドウを開きました。\nデータ読み込みを実行してください。');
		return false;
	}

	if (typeof(tgtWin.document.forms[1]) == 'undefined'){
		alert('対象ウィンドウは、アイテムリストではありません。\nウィンドウの内容を確認してください。')
		return false;
	}

	//フォームから、チェックボックスのリストを取得
	en = tgtWin.document.forms[1].elements.length;
	id = 0;

	for(i=0;i<en;i++){
		if(tgtWin.document.forms[1].elements[i].type == 'checkbox'){
			aryCheck[id] = i;
			aryItemId[id] = tgtWin.document.forms[1].elements[i].value;
			id++;
		}
	}
	maxid = id;
	//全テキストを取得
	text = tgtWin.document.body.innerHTML;

	//選択可能アイテムの始まりを探し、まずそれ以前を捨てる
	sp = text.indexOf('<TD><INPUT type=checkbox',0);
	if (sp == -1){
		alert('対象ウィンドウには、チェック対象のアイテムがありません。\nウィンドウの内容を確認してください。')
		return false;
	}

	text = text.slice(sp,text.length);

	for(id=0;id<maxid;id++){
		//アイテムの終わりを探し、それ以前を現状値として処理。
		len = text.length;
		sp = text.indexOf('</TR>',0);
		current = text.slice(0, sp);
		text = text.slice(sp + 7,len);

		//カレントに対して、データ取得処理
		current = current.replace(/[\n\r]/g,'');
		//<TD>で分離
		aryBuf = current.split('<TD')
		aryImp[id] = aryBuf[2].indexOf('【');

		sp = aryBuf[3].indexOf('">');
		sp2 = aryBuf[3].indexOf('</A');
		aryName[id] = aryBuf[3].slice(sp+2,sp2);

		sp = aryBuf[4].indexOf('title=');
		sp2 = aryBuf[4].indexOf('>');
		sp3 = aryBuf[4].indexOf('<');

		aryType[id] = aryBuf[4].slice(sp2+1,sp3).replace(/◎+/,'');

		fullType = aryBuf[4].slice(sp+6,sp2);
		sp = fullType.indexOf(aryType[id]);
		aryExt[id] = fullType.slice(0,sp);

		aryLevel[id] = aryBuf[5].slice(1,-5);
		aryIni[id] = aryBuf[6].slice(1,-5);
		aryVit[id] = aryBuf[7].slice(1,-5);
		aryDex[id] = aryBuf[8].slice(1,-5);
		aryPsy[id] = aryBuf[9].slice(1,-5);

		aryAbl[id] = aryBuf[10].slice(15,-9);

		aryEqu[id] = aryBuf[11].indexOf('<INPUT');

		debug(id + ' / ' + maxid);

	}

	out = '';
	for(id=0;id<maxid;id++){
		out = out + id + '   ';
		out = out + aryItemId[id] + '   ';
		out = out + aryName[id] + '   ';
		out = out  + aryLevel[id] + '   ';
		out = out  + aryExt[id] + ' ';
		out = out  + aryAbl[id] + ' ';
		out = out  + aryType[id] + '   ';

		out = out  + aryIni[id] + '  ';
		out = out  + aryVit[id] + '  ';
		out = out  + aryDex[id] + '  ';
		out = out  + aryPsy[id] + '  ';

		out = out  + aryEqu[id] + '  ';
		out = out  + aryImp[id] + '\n';
	}

	debug(out);

	alert('データ読み込み完了');
	return true;
}


function checkIt(){
	aryExtList = new Array();

	if (maxid == 0){
		alert('データが読み込まれていません。\nデータを読み込みます。');
		if (analyzePage()){
			alert('データを読み込みました。\nチェックをやりなおしてください。');
		}
		return;
	}

	for(id=0;id<maxid;id++){
		if (aryItemId[id] != tgtWin.document.forms[1].elements[aryCheck[id]].value){
			alert('アイテム欄の内容が食い違っています。\nデータを読み込みなおします。')
			analyzePage();
			alert('データを読み込みなおしました。\nチェックをやりなおしてください。');
			return;
		}
		tgtWin.document.forms[1].elements[aryCheck[id]].checked = false;
	}

	levelMin = eval(document.fm.levelMin.value);
	levelMax = eval(document.fm.levelMax.value);
	notAbility = document.fm.notAbility.checked;
	notExtension = document.fm.notExtension.checked;

	extList = document.fm.extList.value;

	if (extList.length > 0){
		extList = extList.replace(/[\n\r\t ]/g,' ');
		extList = extList.replace(/ +/g,' ');
		extList = extList.replace(/^ +/g,'');
		extList = extList.replace(/ +$/g,'');
		document.fm.extList.value = extList;
		aryExtList = extList.split(' ');
	}

	OUTER:
	for(id=0;id<maxid;id++){
		if (aryLevel[id] < levelMin){ continue; }
		if (aryLevel[id] > levelMax){ continue; }

		if ((notAbility) && (aryAbl[id] != '')){ continue; }
		if ((notExtension) && (aryExt[id] != '')){ continue; }

		for (i=0;i<aryExtList.length;i++){
			if (aryExt[id].indexOf(aryExtList[i]) >= 0){
				continue OUTER;
			}
		}

		tgtWin.document.forms[1].elements[aryCheck[id]].checked = true;
	}

	alert('チェック終了');
}

function debug(val){
	document.fm.debug.value=val;
}


</script>
</head>
<body>

<form name="fm">

<select name="cgimode">
<option value="weapon">武器
<option value="armor">防具
<option value="shield">盾
<option value="item">道具
</select>
<select name="cgilines">
<option value="100">100
<option value="250">250
<option value="500">500
<option value="1000">1000
<option value="all" selected>一括
</select>
<input value="ウィンドウオープン" type="button" onClick="openPage()">

  <input value="データ読み込み" type="button" onClick="analyzePage()">

<hr>

レベル下限<input name="levelMin" value="0" size="4">
 レベル上限<input name="levelMax" value="100" size="4">
<br>
<br>

アビリティが使えるものはチェック対象外
<input name="notAbility" type="checkbox">
<br>
<br>

強化属性があるものはチェック対象外
<input name="notExtension" type="checkbox">
<br>
<br>

以下のリスト(スペースで区切る)に含まれる強化属性はチェック対象外<br>
<textarea name="extList" rows="5" cols="100" wrap="soft"></textarea>
<br>
<br>
<input value="この条件でチェック" type="button" onClick="checkIt()">

<hr>

<textarea cols="100" rows="20" name="debug" wrap="off">
</textarea>

</form>
</body>
</html>

SEO [PR] 爆速!無料ブログ 無料ホームページ開設 無料ライブ放送