(function(h){var q=false;
var s={type:"index",preferenceAttr:"id",highLight:true,border:"yellow 2px solid",expansion:0,fullPath:true};
var p,i;
var a=false;
var j;
var f="";
var n="";
var k=0;
h.fn.getQuery=function(){s=h.extend({type:"xpath",fullPath:true,preferenceAttr:"index",},s||{});
var t=b(this,"");
if(t.substr(0,1)=="/"){t=t.substr(1);
}p=t.replaceAll("/",">").replaceAll("\\[",":eq(").replaceAll("\\]",")").replaceAll("\\:eq\\(\\@","[").replaceAll("'\\)","']");
if(s.fullPath){i="/"+t;
}if(s.type=="selector"){return p;
}else{return i;
}};
this.getXpath=function(){return i;
};
function o(x){var u;
u=h("input#inputxpath",parent.document).val();
if(u.substr(0,1)=="/"){u=u.substr(1);
}var w=/\[(\d+?)\]/;
var v,t=[];
while(t=w.exec(u)){v=parseInt(t[1])-1;
if(v<0){v=0;
}u=u.replace(w,"%"+v+"#");
}u=u.replace(/%/g,"[").replace(/#/g,"]");
u=u.replaceAll("/",">").replaceAll("\\[",":eq(").replaceAll("\\]",")").replaceAll("\\:eq\\(\\@","[").replaceAll("'\\)","']");
if(u&&h(u).length){h(u).highLight();
}else{h("input#inputxpath",parent.document).focus();
alert("请设定正确的Xpath地址！");
}}h.fn.highLight=function(){s=h.extend({border:"yellow 1px solid",expansion:3,},s||{});
if(!h("#eminer7903_abs-box").length){h("body").append("<div id='eminer7903_abs-box' class='abs'></div>");
if(!a){h("head").append("<style>.abs{position:absolute;zoom:1;pointer-events:none;z-index:1999;}</style>");
a=true;
}}var t=h("#eminer7903_abs-box");
if(t!=this){var w=this.offset(),u=s.expansion;
try{t.css({left:w.left-u,top:w.top-u,width:this.width()+2*u,height:this.height()+2*u});
}catch(v){alert(this);
}t.css({"background-color":s.bgColor,border:s.border});
}};
function c(w,v){$objparent=w.parent();
if(q&&!l($objparent)&&$objparent[0]!=document){$objparent.highLight();
var u=b($objparent);
if(u.substr(0,1)=="/"){u=u.substr(1);
}var t=(s.fullPath?"/":"")+u;
h("input#inputxpath",parent.document).val(t);
setTimeout(function(){c($objparent,v);
},v);
}else{q=false;
}}function b(w){if(l(w)||w==window){return"";
}var u=w.get(0).tagName;
if(l(u)){return"";
}var t=g(w);
u=u.toLowerCase()+t;
var v=w.parent();
if(l(v)||v==window||(!s.fullPath&&t.substring(0,5)=="[@id=")){return u;
}else{return b(v)+"/"+u;
}}function g(y){var u=y.get(0).tagName;
if(s.preferenceAttr.toLowerCase()!="index"){var z=y.attr("id"),v=y.attr("class");
var x=!l(z),t=!l(v);
z="[@id='"+z+"']";
v="[@class='"+v+"']";
if(x&&t){if(s.preferenceAttr.toLowerCase()=="class"){return v;
}else{return z;
}}else{if(x&&!t){return z;
}else{if(!x&&t){return v;
}}}}if(y.siblings(u).size()>0){var w=y.prevAll(u).size();
if(s.type=="xpath"){w++;
}return"["+w+"]";
}else{return"";
}}function l(t){return typeof t=="undefined"||null==t||"null"==t||""==t||undefined==t||t==false||t.length==0;
}function d(v,u,t){var u=l(u)?1:u;
var t=l(t)?1:t;
e=v?v:window.event;
if(!e){e=getEvent();
}if(!e){return null;
}if(u){if(e.preventDefault){e.preventDefault();
}else{e.returnValue=false;
}}if(t){if(e.stopPropagation){e.stopPropagation();
}else{e.cancelBubble=true;
}}return e;
}var m=function(v){if(q==true){q=false;
return false;
}q=false;
v=v||window.event;
d(v);
var u=v.target||v.srcElement;
u=j;
var t=h(u).getQuery();
f=n;
n=t;
h("input#inputxpath",parent.document).val(n);
if(parent.document.getElementById("xpathpubble").checked==true){var w=parseFloat(parent.document.getElementById("pubbledelayinput").value)*1000;
setTimeout(function(){q=true;
c(h(u),w);
},w);
}return false;
};
var r=function(v){v=v||window.event;
d(v);
var u=v.target||v.srcElement;
if(h(u).is("#eminer7903_abs-box")){return false;
}if(j==u){return false;
}q=false;
j=u;
var t=h(u).highLight();
return false;
};
h(document).click(m);
h(document).mousemove(r);
h("input#xpathhighlight",parent.document).click(o);
h("input#getlastxpathbutt",parent.document).click(function(x){if(!f||!n){h(this).siblings("span#xpathinfo").text("请连续点击两个同类链接，然后再点击本按钮以获取通用Xpath。");
var t=this;
setTimeout('$("input#getlastxpathbutt",parent.document).siblings("span#xpathinfo").text("");',5000);
return;
}var u=f.split("/");
var z=n.split("/");
var v=0;
for(var w in u){if(u[w]!=z[w]){xlastpath1=u[w].split("[");
xnewpath1=z[w].split("[");
u[w]=xlastpath1[0];
z[w]=xnewpath1[0];
v++;
}}if(v>2){h(this).siblings("span#xpathinfo").text("请连续点击两个同类链接，然后再点击本按钮以获取通用Xpath。");
setTimeout('$(this).siblings("span#xpathinfo").text("");',5000);
setTimeout('$("input#getlastxpathbutt",parent.document).siblings("span#xpathinfo").text("");',5000);
return;
}var y=z.join("/");
h("input#inputxpath",parent.document).val(y).focus();
h(this).next("span").text("已在Xpath地址框内成功生成通用Xpath。请复制获取");
setTimeout('$("input#getlastxpathbutt",parent.document).next("span").text("");',5000);
});
})(jQuery);
String.prototype.replaceAll=function(b,a){return this.replace(new RegExp(b,"gm"),a);
};
