- 注册时间
- 2012-6-14
- 最后登录
- 2018-4-2
- 阅读权限
- 10
- 积分
- 633
- 精华
- 0
- 帖子
- 138
|
niko 发表于 2012-9-21 07:23
document.attachEvent("onmouseup", function(){
var text = document.selection. ...
下面 这段是动态 解析的 javascript代码
VUS.SearchWord = {
version:"20002",
EM:"<EM vus_zhaokan=\"KEYWORD\" style=\"color:#ff0000;font-style:normal\">KEYWORD</EM>",
EMU:"<EM style=\"color:#ff0000;font-style:normal;cursor:hand\" > \
<U onclick = \"VUS.SearchWord.OnEmMouseDown(this)\" vus_zhaokan=\"KEYWORD\">KEYWORD</U></EM>",
FilterSite:[
"youku.com", "tudou.com", "qiyi.com", "xunlei.com", "iqiyi.com", "tv.sohu.com", "v.qq.com",
"letv.com", "ku6.com", "56.com", "pptv.com", "v.pps.tv", "cntv.com", "video.sina.com.cn",
"kankan.com", "sandai.net"
],
IsBlackSite:function(){
for(var i=0; i<this.FilterSite.length; i++){
if(document.URL.indexOf(this.FilterSite)>=0){
return true;
}
}
return false;
},
OnEmMouseDown:function(elem){
var keyword = elem.getAttribute("vus_zhaokan", 0);
if(typeof(keyword)=="string"){
this.SearchWrodInXmp(keyword);
window.event.cancelBubble = true;
window.event.returnValue = false;
}
},
SearchWrodInXmp:function(keyword){
var sCmdLine = "/sstartfrom iesearchword /skeyword " + keyword;
var bIsXmpExist = VUS.vusbho.JsCall("IsXmpExist");
if(bIsXmpExist){
var dapCtrl = VUS.Utility.GetDapCtrl();
if(dapCtrl){
dapCtrl.Put("sxmp4arg", sCmdLine);
}
var oParam = {u1:"searchword", u2:"clickword", u3:keyword, u4:document.URL};
VUS.Utility.SendConvStat(oParam, VUS.SearchWord.version);
}else{
alert("您未安装迅雷看看播放器,请安装迅雷看看播放器后进行搜索播放");
window.open("http://dl.xunlei.com/xmp.html?from=sniffer", "_blank");
var oParam = {u1:"searchword", u2:"exception", u3:"missingxmp"};
VUS.Utility.SendConvStat(oParam, VUS.SearchWord.version);
}
},
SearchKeyWord:function(){
var aTargetElems = new Array();
var aAll = document.body.all;
for(var i=0; i<aAll.length; i++){
var elem = aAll;
if(elem.style.visibility!="hidden" && elem.style.display!="none"){
var aChildren = elem.children;
if(aChildren.length==0){
if(elem.outerText.length>0){
var aRet = elem.outerText.match(VUS.SearchWord.sRegKeyWord);
if(aRet){
aTargetElems.push({targetelem:elem, keyword:aRet[0]});
}
}
}else{
var bCan = true;
for(var c=0; c<aChildren.length; c++){
var cElem = aChildren[c];
if(cElem.tagName==="!"){}
else{
bCan = false;
break;
}
}
if(bCan){
if(elem.outerText.length>0){
for(var j=0; j<this.KeyWord.length; j++){
if(elem.innerHTML.indexOf(this.KeyWord[j])>=0){
aTargetElems.push({targetelem:elem, keyword:this.KeyWord[j]});
break;
}
}
}
}
}
}
}
if(aTargetElems.length>0){
var oParam = {u1:"searchword", u2:"hitword", u3:String(aTargetElems.length), u4:document.URL};
VUS.Utility.SendConvStat(oParam, VUS.SearchWord.version);
var sReplace = "";
if(this.searchLevel==1){
sReplace = this.EM;
}else if(this.searchLevel==2){
sReplace = this.EM;
}else{
return;
}
for(var index=0; index<aTargetElems.length; index++){
var elem = aTargetElems[index].targetelem;
var keywrod = aTargetElems[index].keyword;
var rKeyWord = sReplace.replace(/KEYWORD/g, keywrod);
var innerHTML = elem.innerHTML.replace(keywrod, rKeyWord);
elem.innerHTML = innerHTML;
}
aTargetElems = null;
return true;
}
return false;
},
CreateFloatDiv:function(){
var oDiv = document.createElement("div");
oDiv.id = "vud_div";
oDiv.style.width = "81px"
oDiv.style.height = "24px"
oDiv.style.position = "absolute"
oDiv.style.zIndex = "1999999"
oDiv.style.backgroundColor = "transparent";
oDiv.style.visibility = "hidden";
oDiv.style.cursor = "hand";
oDiv.innerHTML= "<img id=vus_searchword_img src= 'http://conf.xmp.xunlei.com/vusjs/normal.png'>";
oDiv.onclick = function(){
VUS.SearchWord.SearchWrodInXmp(this.keyword);
};
oDiv.onmouseover = function(){
var oImg = document.getElementById("vus_searchword_img");
if(oImg){
oImg.src = "http://conf.xmp.xunlei.com/vusjs/normal.png";
}
};
oDiv.onmouseout = function(){
var oImg = document.getElementById("vus_searchword_img");
if(oImg){
oImg.src = "http://conf.xmp.xunlei.com/vusjs/hover.png";
}
};
document.body.appendChild(oDiv);
},
AttachEvent:function(){
document.attachEvent("onmouseover", function(){
if(typeof(VUS.SearchWord)!="object"){
return;
}
var elem = window.event.srcElement;
var hasdiv=document.getElementById("vud_div");
var zhaokan = elem.getAttribute("vus_zhaokan", 0);
if(typeof(zhaokan)=="string"){
if(hasdiv!=null){
var x = VUS.Utility.GetElementLeft(elem)-(hasdiv.offsetWidth-elem.offsetWidth)/2;
var y = VUS.Utility.GetElementTop(elem)-hasdiv.offsetHeight;
hasdiv.style.visibility = "visible";
hasdiv.style.left = x +"px";
hasdiv.style.top = y + "px";
hasdiv.x = x;
hasdiv.y = y;
hasdiv.keyword = zhaokan;
}
}else{
if(hasdiv!=null){
if(hasdiv.style.visibility != "hidden"){
var x1 = hasdiv.x;
var y1 = hasdiv.y;
var x2 = x1 + hasdiv.offsetWidth;
var y2 = y1 + hasdiv.offsetHeight+5;
var cursorX = window.event.clientX;
var cursorY = window.event.clientY+document.documentElement.scrollTop;
var bShow = (x1<=cursorX && cursorX<=x2) && (y1<=cursorY && cursorY<=y2);
if(!bShow){
hasdiv.style.visibility = "hidden";
}
}
}
}
}, false);
},
IsPreDeal:function(){
var sXmpVersion = VUS.vusbho.JsCall("GetXmpVersion");
var oRet = sXmpVersion.match("4.9.1");
if(oRet!=null){
return true;
}else{
oRet = sXmpVersion.match("4.9.0");
if(oRet!=null){
var sPath = VUS.vusbho.JsCall("GetAppDataPath", "Thunder Network\\XMP4\\xar\\plugins\\searchwordplugin.xar");
var bRet = VUS.vusbho.JsCall("PathFileExists", sPath);
return bRet;
}else{
var sPath = VUS.vusbho.JsCall("GetAppDataPath", "Thunder Network\\XMP4\\xar\\plugins\\searchwordplugin");
var bRet = VUS.vusbho.JsCall("PathFileExists", sPath);
return bRet;
}
}
},
GetKeyWordUrl:function(){
var keywordurl = "";
var date = new Date();
if(VUS.Utility.AreaInfo.areano==1){
keywordurl = "http://images.client.xunlei.com/huaci_title.js?rd="+date.getHours();
this.searchLevel = 1;
}else{
keywordurl = "http://images.client.xunlei.com/huaci_title_full.js?rd="+date.getHours();
this.searchLevel = 1;
}
return keywordurl;
},
LoadKeyWords:function(){
var keywordurl = this.GetKeyWordUrl();
VUS.Utility.DownloadUrl(keywordurl, function(responseText, status){
if(status==200){
if(typeof(responseText)=="string" && responseText.length>0){
window.execScript(responseText);
if(typeof(huaci_title)=="object"){
VUS.SearchWord.KeyWord = huaci_title;
VUS.SearchWord.sRegKeyWord = "/" + VUS.SearchWord.KeyWord.join("|") + "/";
huaci_title = null;
var bRet = VUS.SearchWord.SearchKeyWord();
if(bRet){
VUS.SearchWord.CreateFloatDiv();
VUS.SearchWord.AttachEvent();
}
}
}
}
});
},
Deal:function(){
var bPreDeal = this.IsPreDeal();
var bIsBlack = this.IsBlackSite();
if(!bPreDeal || bIsBlack) return;
VUS.Utility.GetAreaInfo(function(){
VUS.SearchWord.LoadKeyWords();
});
document.attachEvent("onmouseup", function(){
var text = document.selection.createRange().text;
if(typeof(text)=="string"){
if(2<=text.length && text.length<=50){
var key = "VUS-SearchWordJs-" + VUS.SearchWord.version + "-SelectWord";
var oParam = {u1:"searchword", u2:"selectedtext", u3:text, u4:document.URL};
VUS.Utility.SendConvStat(oParam, VUS.SearchWord.version);
}
}
}, false);
}
};
(function(){
VUS.SearchWord.Deal();
})(); |
|