2。可以改造成通用的自动发mail. 自动帖子回复等。(但是目前不支持验证码。)
<!--
*******************************************************************
* file name : StartWizard.htm
* description: function of HTML GUI process.
* system : source code engine.
* :
* auth : [url]www.ec-current.com[/url]
* date :
* revise memo: 2006/01/02
****************************************************************
-->
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<SCRIPT language=javascript>
var externalClass = function()
{
this.name = "this is help for the window.external";
this.setTimeOut = function(intTime)
{
log("setTimeOut:" + intTime);
return "";
}
this.Navigate = function(strUrl)
{
log("Navigate:" + strUrl);
return "";
}
this.AddPostKey = function(strName,strValue,strType)
{
log("setInputValue:" + strName + "=" + strValue);
return "";
}
this.SelectOption = function(strName,strValue,strType)
{
log("setInputValue:" + strName + "=" + strValue);
return "";
}
this.submit = function(strFormName)
{
log("submit:" + strFormName );
return "";
}
this.sendMail = function(strMsg,strMailAddr,strMailSvr,strUsr,strPsw)
{
log("sendMail:" + strMailAddr + strMailSvr + strUsr + strPsw);
return "";
}
this.InvokeScript = function(strScript,strArgs,bol_wait)
{
log("InvokeScript:" + strScript + strArgs);
return "";
}
this.eval= function(strScript,bol_wait)
{
log("eval:" + strScript );
return "";
}
this.getTargetWindow = function()
{
log("getTargetWindow:" );
return "";
};
this.getTargetWindowText = function()
{
log("getTargetWindowText:" );
return "";
};
}
function log(strText)
{
document.getElementById("msg").innerText += strText;
document.getElementById("msg").innerHTML += "<hr />";
}
function logclear()
{
document.getElementById("msg").innerHTML = "";
}
/////////////////////////////////////////////////////
function main() // this is the entry point.
{
ur_net();
}
/////////////////////////////////////////////////////
function ur_net()
{
var objD = new Date();
var hh = objD.getUTCHours();
var mm = objD.getUTCMinutes();
if( (hh>=9 && hh<=10)
|| (hh>=15 && hh<=16)
)
{
window.setTimeout(ur_net, 1000*60*10) ; // check each 10 minutes.
}
else if(hh>=10 && hh<=15)
{
window.setTimeout(ur_net, 1000*60*40) ; // check each 40 minutes.
}
else
{
window.setTimeout(ur_net, 1000*60*60) ; // check each 60 minutes.
}
var obj = new externalClass();
obj.Navigate("http://sumai.ur-net.go.jp/Sumai/10/Index.html");
obj.InvokeScript("postLink","'comTopPage','ArrNormalConditionSearchAction','top','arrNormalSearch'",true);
obj.SelectOption("railroadLineNamesS", "JR京浜東北線","");
//1.1駅を探す
obj.eval("postLinkChangeAction('arrNormalConditionSearch','ArrNormalConditionSearchAction','getStation','http://sumai.ur-net.go.jp/Sumai/Servlet/SumaiCommon','arrNormalSearch');",true);
//1.2部屋を探す
obj.SelectOption("stationNamesS", "JR京浜東北線 蕨","");
obj.eval("postLinkChangeAction('arrNormalConditionSearch','ArrNormalConditionSearchAction','searchApartment','http://sumai.ur-net.go.jp/Sumai/Servlet/SumaiCommon','arrNormalSearch');",true);
var strText = obj.getTargetWindowText();
log(strText);
//2.1 check is it mail.
var m = strText.indexOf("1LDK");
var n = strText.indexOf("3DK");
if(m>0 || n>0)
{
//send mail,象设置outlook一样设置mail服务器。
obj.sendMail("check 3dk.","XX@X.jp,[email]XX@X.jp[/email]","XXX.jp","xxx","xxxx");
}
//2.2 check if auto order it.
//debugger; //use this to debug javascript;
m = strText.indexOf("105"); //alert(m);
n = strText.indexOf("3DK",m>0?m:99);
var strScript;
if(m>0 && n>0)
{
m = strText.indexOf("postLinkForArrBook",n);
if(m>0)
{
n = strText.indexOf(")",m);
if(n>0)
{
strScript = strText.substring(m,n); //strText.substr(m,n-m);
strScript += ");";
log(strScript);
obj.eval(strScript,true);
//
strText = obj.getTargetWindowText();
if(0 < strText.indexOf("userIdS")
&& 0 < strText.indexOf("passwordS")
)
{
//set userIdS
obj.AddPostKey("userIdS", "XXXXX","");
obj.AddPostKey("passwordS", "XXXXX","");
obj.eval("postLinkChangeAction('UserLogin','UserLoginAction','login','https://sumai.ur-net.go.jp/Sumai/Servlet/SumaiCommon','arrNormalBook');",true);
//set keywordS
obj.AddPostKey("keywordS", "XXXX","");
obj.eval("postLinkChangeAction('UserKeyword','UserLoginAction','loginKeyword','https://sumai.ur-net.go.jp/Sumai/Servlet/SumaiCommon','arrNormalBook');",true);
strText = obj.getTargetWindowText();
}
if(0 < strText.indexOf("ArrNormalBookSpecial"))
{
// order it.
obj.eval("postLinkChangeAction('ArrNormalBookSpecial','ArrNormalBookAction','editEnd','https://sumai.ur-net.go.jp/Sumai/Servlet/SumaiCommon','arrNormalBook');",true);
}
else
{
//undo the last order. ご予約の物件がございます
//1.goto mypage.
obj.eval("postLinkChangeAction('navigationBar','UserLoginAction','top','https://sumai.ur-net.go.jp/Sumai/Servlet/SumaiCommon','mypage');",true);
obj.eval("postLinkChangeAction('Mypage','ArrNormalApplyAction','top','https://sumai.ur-net.go.jp/Sumai/Servlet/SumaiCommon','mypage');",true);
obj.eval("postLinkChangeAction('arrNormalApplyWay','ArrNormalCancelAction','top','https://sumai.ur-net.go.jp/Sumai/Servlet/SumaiCommon','arrNormalCancel');",true);
debugger;
obj.AddPostKey("inspectionFlagN", "false","radio");
obj.AddPostKey("cancelReasonEnvFlagN", "true","checkbox");
obj.eval("postLinkChangeAction('arrNormalCancel','ArrNormalCancelAction','cancel','https://sumai.ur-net.go.jp/Sumai/Servlet/SumaiCommon','arrNormalCancel');",true);
// redo it.
window.setTimeout(ur_net, 1000);
}
}
}
}
return true;
}
function test0()
{
var obj = new externalClass();
obj.setTimeOut(100);
obj.Navigate("http://localhost/office/sales/main.asp");
obj.AddPostKey("id", "XXXXX","");
obj.AddPostKey("key", "XXXXX","");
obj.AddPostKey("cmdLogin", "login","");
obj.submit("");
return false;
}
</SCRIPT>
<table class="partsmb fixedTable" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr><td class="MPEdit"><a class="MPEdita" href="#" onclick="javascript:main();return false;" >begin main.</a> </td></tr>
<tr><td class="MPInfo">start the main function.<br></td></tr>
</tbody>
</table>
<br />
<table class="partsmb fixedTable" border="0" cellpadding="0" cellspacing="0" width="100%">
<tbody>
<tr></tr>
</tbody>
</table>
</tbody>
</table>
<div id = "msg" name = "msg" ></div>
</html>