TRAPOKE_SITECODE_JALAN = 501; TRAPOKE_SITECODE_RAKUTEN_TRAVEL = 502; TRAPOKE_SITECODE_IKKYU = 503; TRAPOKE_SITECODE_YAHOO_TRAVEL = 504; TRAPOKE_SITECODE_EXPEDIA = 505; TRAPOKE_SITECODE_AGODA = 506; TRAPOKE_SITECODE_JTB = 507; TRAPOKE_SITECODE_KINKI_NIPPON_TOURIST = 508; TRAPOKE_SITECODE_NIPPON_TRAVEL_AGENCY = 509; TRAPOKE_SITECODE_RURUBU_TRAVEL = 510; TRAPOKE_SITECODE_TRIP_DOT_COM = 511; TRAPOKE_SITECODE_UNKNOWN = 999; TRAPOKE_VIEW_NONE = 0; TRAPOKE_VIEW_DETAIL = 1; TRAPOKE_VIEW_LIST = 2; function isTrapokeSite(url) { if (url.match(/jalan\.net\//)) { return TRAPOKE_SITECODE_JALAN; } if (url.match(/travel\.yahoo\.co\.jp\//)) { return TRAPOKE_SITECODE_YAHOO_TRAVEL; } if (url.match(/travel\.rakuten\.co\.jp\//)) { return TRAPOKE_SITECODE_RAKUTEN_TRAVEL; } return TRAPOKE_SITECODE_UNKNOWN; } function isTrapoke(url) { if (url.match(/travel-api\.kaipoke\.jp\//)) { log("not match"); return [TRAPOKE_VIEW_NONE, TRAPOKE_SITECODE_UNKNOWN]; } if (url.match(/jalan\.net\/yad/)) { return [TRAPOKE_VIEW_DETAIL, TRAPOKE_SITECODE_JALAN]; } if (url.match(/jalan\.net\/\d{6}\/LRG_\d{6}\//)) { return [TRAPOKE_VIEW_LIST, TRAPOKE_SITECODE_JALAN]; } if (url.match(/travel\.yahoo\.co\.jp\/[0-9]+\//)) { return [TRAPOKE_VIEW_DETAIL, TRAPOKE_SITECODE_YAHOO_TRAVEL]; } if (url.match(/search\.travel\.rakuten\.co\.jp\//)) { return [TRAPOKE_VIEW_LIST, TRAPOKE_SITECODE_RAKUTEN_TRAVEL]; } if (url.match(/travel\.rakuten\.co\.jp\/yado\//)) { return [TRAPOKE_VIEW_LIST, TRAPOKE_SITECODE_RAKUTEN_TRAVEL]; } if (url.match(/travel\.rakuten\.co\.jp\/HOTEL\/[0-9]+\/[0-9]+\.html/)) { return [TRAPOKE_VIEW_DETAIL, TRAPOKE_SITECODE_RAKUTEN_TRAVEL]; } if (url.match(/travel\.rakuten\.co\.jp\/HOTEL\/[0-9]+\//)) { return [TRAPOKE_VIEW_DETAIL, TRAPOKE_SITECODE_RAKUTEN_TRAVEL]; } if (url.match(/hotel\.travel\.rakuten\.co\.jp\/hotelinfo\//)) { return [TRAPOKE_VIEW_DETAIL, TRAPOKE_SITECODE_RAKUTEN_TRAVEL]; } if (url.match(/hotel\.travel\.rakuten\.co\.jp\/hinfo\//)) { return [TRAPOKE_VIEW_DETAIL, TRAPOKE_SITECODE_RAKUTEN_TRAVEL]; } return [TRAPOKE_VIEW_NONE, TRAPOKE_SITECODE_UNKNOWN]; } function padValue(value) { return (value < 10) ? "0" + value : value; } // エリア+宿泊日 function jalan(url) { // checkindate var checkindate = ""; var stayyear = url.match(/stayYear=[0-9]+/g); var staymonth = url.match(/stayMonth=[0-9]+/g); var stayday = url.match(/stayDay=[0-9]+/g); if ((null != stayyear && null != staymonth && null != stayday) && (0 != stayyear.length && 0 != staymonth.length && 0 != stayday.length)) { var m = padValue(staymonth[0].split("=")[1]); var d = padValue(stayday[0].split("=")[1]); checkindate = stayyear[0].split("=")[1] + "-" + m + "-" + d; } else { var d = new Date(); checkindate = d.getFullYear() + "-" + ("0" + (d.getMonth() + 1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2); } // エリア情報 URLより取得 var ken_cd = url.match(/kenCd=[0-9]+/g); var small = url.match(/smlCd=[0-9]+/g); var large = url.match(/lrgCd=[0-9]+/g); if( null == ken_cd || ken_cd.length == 0 ){ var match = url.match(/jalan\.net\/([0-9]+)/); ken_cd = match ? match[1] : null; } else { ken_cd = ken_cd[0].split(/=/)[1]; } if( null == large || large.length == 0 ){ var regex = new RegExp("LRG_(\\d+)/"); var match = regex.exec(url); if (match && match.length > 1) { large = match[1]; } else { large = null; } } else { large = large[0].split(/=/)[1]; } if( small == null || small.length == 0 ){ var regex = new RegExp("SML_(\\d+)/"); var match = regex.exec(url); if (match && match.length > 1) { small = match[1]; } else { small = null; } } else { small = small[0].split(/=/)[1]; } //searchHotelsByArea var areaOptions = [{ jalan_area: { small: "", large: "", prefecture: "" } }]; areaOptions[0].jalan_area["small"] = ((small == null || small.length == 0) ? "" : small); areaOptions[0].jalan_area["large"] = ((large == null || large.length == 0) ? "" : large); areaOptions[0].jalan_area["prefecture"] = ((ken_cd == null || ken_cd.length == 0) ? "" : ken_cd); // adult num URLより取得 var adultnum = url.match(/adultNum=[0-9]+/g); // 指定がないときは2 if (null == adultnum || adultnum.length == 0) { adultnum = "2"; } else { adultnum = adultnum[0].split(/=/)[1]; } return [adultnum,checkindate,areaOptions[0].jalan_area]; } function yahoo_travel(url) { var hotelName = ""; if (url.match(/travel\.yahoo\.co\.jp\/[0-9]+\//)) { log('yahoo 施設詳細'); // CheckinDate URLより取得 var checkindate = url.match(/&cid=[0-9]+/g); if (null != checkindate && checkindate.length > 0) { checkindate = checkindate[0].split("=")[1]; checkindate = checkindate.slice(0, 4) + '-' + checkindate.slice(4); checkindate = checkindate.slice(0, 7) + '-' + checkindate.slice(7); } else { var d = new Date(); checkindate = d.getFullYear() + "-" + ("0" + (d.getMonth() + 1)).slice(-2) + "-" + ("0" + d.getDate()).slice(-2); } // adultnum URLより取得 var adultnum = url.match(/&ppc=[0-9]+/g); if (null != adultnum && adultnum.length > 0) { adultnum = adultnum[0].split("=")[1]; } else { adultnum = "2"; } return [adultnum, checkindate]; } } function rakuten_travel(url) { var hotelName = ""; var type = 0; if (url.match(/search\.travel\.rakuten\.co\.jp\//)) { // リスト表示 log('rakuten リスト表示1'); } else if (url.match(/travel\.rakuten\.co\.jp\/yado\//)) { // リスト表示 log('rakuten リスト表示2'); } else if (url.match(/travel\.rakuten\.co\.jp\/HOTEL\/[0-9]+\/[0-9]+\.html/)) { log('rakuten 詳細表示1'); } else if (url.match(/hotel\.travel\.rakuten\.co\.jp\/hotelinfo\//)) { log('rakuten 詳細表示2'); } else if (url.match(/hotel\.travel\.rakuten\.co\.jp\/hinfo\//)) { log('rakuten 詳細表示3'); } // checkinDate var checkindate = ""; var f_nen1 = url.match(/&f_nen1=[0-9]+/g); var f_tuki1 = url.match(/&f_tuki1=[0-9]+/g); var f_hi1 = url.match(/&f_hi1=[0-9]+/g); // 指定が無いときは当日 if ((f_nen1 == null || f_tuki1 == null || f_hi1 == null) || (f_nen1.length == 0 || f_tuki1.length == 0 || f_hi1.length == 0) ) { var today = new Date(); f_nen1 = today.getFullYear(); f_tuki1 = ("0" + (today.getMonth() + 1)).slice(-2); f_hi1 = ("0" + today.getDate()).slice(-2); log("hit"); } else { f_nen1 = f_nen1[0].split("=")[1]; f_tuki1 = f_tuki1[0].split("=")[1]; f_hi1 = f_hi1[0].split("=")[1]; f_tuki1 = ("0" + f_tuki1).slice(-2); f_hi1 = ("0" + f_hi1).slice(-2); log("not hit"); } checkindate = f_nen1 + "-" + f_tuki1 + "-" + f_hi1; log("-------------------checkindate------------------"); log(checkindate); log("-------------------checkindate------------------"); // adultNum var adultNum = url.match(/&f_otona_su=[0-9]+/g); // 指定がないときは2 if (null == adultNum || adultNum.length == 0) { adultNum = "1"; } else { adultNum = adultNum[0].split("=")[1]; } return [adultNum,checkindate]; }