(function(){var n={},t=function(t,i,r,u){var f=FlightFactory.getFromCtrip(t,i,r);f.getData(!1,!0,function(){Storage.set("showStage",{name:"promotion",data:{query:{from:CityMap.code2name[t],to:CityMap.code2name[i]},tickets:f.getData(),referer:u}});Storage.set("promotionTime",Util.date.now());n={};Util.popup()})};chrome.webRequest.onCompleted.addListener(function(i){var o=Storage.get("promotionTime"),u,f,r,e;o!==null&&o!==undefined&&Util.date.now()-parseInt(o,10)<config.promotion.silent||(r=i.url.match(/booking\/(.*\-.*)\-day\-1\.html/),typeof r!="undefined"&&r!=null&&typeof r[1]!="undefined")&&(u=r[1],typeof n[u]=="undefined"&&(n[u]=0),n[u]++,n[u]>=config.promotion.limit&&(f=u.split("-"),r=i.url.match(/DDate1=([0-9\-]*)/),r===undefined||r===null||r[1]===undefined?chrome.tabs.get(i.tabId,function(n){e=n.title.match(/^[0-9\-]*/);e!==undefined&&e!==null&&e[0]&&t(f[0],f[1],Util.date.formatFromYmd(e[0]),i.url)}):t(f[0],f[1],r[1],i.url)))},{urls:["http://flights.ctrip.com/booking/*"]})})()