以下这段js是在指定的域名前加上字串,想改为在所有的外链签名都加上。比如我的域名是abcd.com。var taobaoke = {
host: "t.pianyi.taobao.com/index.php?m=jump",
userhash: "",
hash: null,
py: null,
inframe: 0,
member: "",
memberUid: 0,
mac: "",
linkInfo: "",
ignore_class: "_J_py_ignore",
whiteList: [/^(onsale\.manyi\.taobao)\.com/i, /^(manyi\.taobao)\.com/i, /^(pianyi\.taobao)\.com/i, /^(remai\.manyi\.taobao)\.com/i, /^(t\.pianyi\.taobao)\.com/i, /^(taomanyi\.taobao)\.com/i, /^(www\.gzmama)\.com/i],
$: function(d) {
return document.getElementById(d)
},
isGecko: function() {
return navigator.userAgent.indexOf("Gecko") == -1 ? false: true
},
isOpera: function() {
return navigator.userAgent.indexOf("Opera") == -1 ? false: true
},
isIE: function() {
return document.all ? true: false
},
isNull: function(d) {
return "" == d || null == d || undefined == d ? true: false
},
isPhpWind: function() {
if (window.winduid != undefined) return true;
return false
},
findObj: function(d) {
for (var i = 0; i < 10; i++) if ("object" == typeof d && typeof d.tagName != "undefined") {
var j = d.tagName.toLowerCase();
if ("a" == j || "area" == j) {
if (this.isIgnoreConvert(d)) break;
return d
}
if ("body" == j) break;
d = d.parentNode
} else break;
return null
},
analyseUrl: function(d) {
d = d.replace(/(^\s*)|(\s*$)/g, "").replace(/^http:\/\//g, "");
return this.urlFilter(d) ? "": /^([\w|\.|-]+\.qq|p\.tenxun|[\w|\.|-]+\.paipai)\.com/i.exec(d) ? "http://" + d: ""
},
urlFilter: function(d) {
var i;
for (i = this.whiteList.length; --i >= 0;) if (this.whiteList[i].exec(d)) return true;
return false
},
secondURI: function(d) {
d = d.replace(/(^\s*)|(\s*$)/g, "").replace(/^http:\/\//g, "");
if (this.urlFilter(d)) return "";
if (/(^|\?|&)[^&]*=([^&]+.paipai.com[^&]*)(\s|&|$)/i.test(d)) return unescape(RegExp.$2.replace(/\+/g,
" "));
return ""
},
foundAdd: function() {
var d = "&sitehash=" + this.userhash + "&winduid=" + this.member + "&windid=" + this.memberUid;
if (0 == this.inframe) d += "&from=" + encodeURIComponent(window.location.href);
else {
var i = this.referer();
this.isNull(i) || (d += "&from=" + encodeURIComponent(i))
}
if (this.isNull(this.getck("mac"))) {
this.setck("mac", this.hash);
this.mac = this.hash
} else this.mac = this.getck("mac");
d += "&mac=" + this.mac + "&py=" + this.py;
this.linkInfo = d
},
referer: function() {
var d = document.referrer;
if (!d) try {
if (window.opener) d =
window.opener.location.href
} catch(i) {}
return d
},
linkify: function(d) {
var i,
j;
if (d.nodeType == 3) {
i = d.data.search(/((https?)|(ftp))\:\/\/[^\s]*[^.,">\s\)\]]/);
if (i >= 0) {
i = d.splitText(i);
i.splitText(RegExp.lastMatch.length);
j = document.createElement("A");
j.href = i.data;
j.target = "_blank";
j.appendChild(i);
d.parentNode.insertBefore(j, d.nextSibling)
}
i = d.data.search(/www[^\s]*[^.,">\s\)\]]/);
if (i >= 0) {
i = d.splitText(i);
i.splitText(RegExp.lastMatch.length);
j = document.createElement("A");
j.href = "http://" + i.data;
j.target =
"_blank";
j.appendChild(i);
d.parentNode.insertBefore(j, d.nextSibling)
}
} else if (d.tagName != "STYLE" && d.tagName != "SCRIPT" && d.tagName != "A") for (i = 0; j = d.childNodes[i]; ++i) this.linkify(j)
},
hasClass: function(d, i) {
return d.className.indexOf(i) != -1
},
isIgnoreConvert: function(d) {
if (this.hasClass(d, this.ignore_class)) return true;
else if ("object" == typeof d.parentNode) return this.hasClass(d.parentNode, this.ignore_class)
},
loopFrames: function(d) {
for (var i = 0; i <= d.length; i++) try {
b = d.document.body;
b.normalize();
this.linkify(b)
} catch(j) {}
},
__main__: function() {
this.getWindid();
this.getWinduid();
this.inframe = window != parent;
this.foundAdd();
this._rewritePWchickUrl()
},
setck: function(d, i) {
var j = new Date,
l = (24 - j.getHours()) * 36E5;
j.setTime(j.getTime() + l);
document.cookie = d + "=" + escape(i) + ";expires=" + j.toGMTString()
},
getck: function(d) {
d = document.cookie.match(RegExp("(^| )" + d + "=([^;]*)(;|$)"));
if (d != null) return unescape(d[2]);
return null
},
getWindid: function() {
if (typeof window.windid != undefined) this.member = window.windid
},
getWinduid: function() {
if (typeof window.winduid !=
undefined) this.memberUid = window.winduid
},
_rewritePWchickUrl: function() {
var d = this;
if (this.isPhpWind() == true && typeof window.checkUrl == "function") {
var i = window.checkUrl;
window.checkUrl = function(j) {
var l = j.href,
k = d.analyseUrl(j.href);
if (1 < k.length) {
k = "http://" + d.host + "&to=" + encodeURIComponent(k) + d.linkInfo;
j.href = k
}
k = i(j);
j.href = l;
return k
}
}
},
chushi: function() {
return this
},
pwhash: function(d) {
if (!this.isNull(d)) this.userhash = d
},
creathash: function() {
var d = new Date,
i = d.getYear(),
j = d.getMonth() + 1,
l = d.getDate(),
k = d.getHours(),
n = d.getMinutes();
d = d.getSeconds();
i = i + "-" + j + "-" + l + " " + k + ":" + n + ":" + d + this.member + this.memberUid + this.userhash;
this.hash = i = this.hex_md5(i)
},
exchange: function() {
var d = this;
this.__main__();
document.onclick = function(i) {
try {
i = i || window.event;
var j = i.target || i.srcElement;
j = d.findObj(j);
if (null != j) {
var l = d.analyseUrl(j.href);
if (1 > l.length) {
l = d.secondURI(j.href);
if (1 > l.length) return
}
//http://"+a.host+"?app="+pid+"&urll="+c
var k = "http://" + host + "&urll=" + l ;
if (j.target == "_blank") {
var n = j.href;
setTimeout(function() {
j.href =
n
},
500)
}
j.href = k
}
} catch(a) {
return 1
}
}
},
setpy: function(d) {
if (!this.isNull(d)) this.py = d
}
};
host: "t.pianyi.taobao.com/index.php?m=jump",
userhash: "",
hash: null,
py: null,
inframe: 0,
member: "",
memberUid: 0,
mac: "",
linkInfo: "",
ignore_class: "_J_py_ignore",
whiteList: [/^(onsale\.manyi\.taobao)\.com/i, /^(manyi\.taobao)\.com/i, /^(pianyi\.taobao)\.com/i, /^(remai\.manyi\.taobao)\.com/i, /^(t\.pianyi\.taobao)\.com/i, /^(taomanyi\.taobao)\.com/i, /^(www\.gzmama)\.com/i],
$: function(d) {
return document.getElementById(d)
},
isGecko: function() {
return navigator.userAgent.indexOf("Gecko") == -1 ? false: true
},
isOpera: function() {
return navigator.userAgent.indexOf("Opera") == -1 ? false: true
},
isIE: function() {
return document.all ? true: false
},
isNull: function(d) {
return "" == d || null == d || undefined == d ? true: false
},
isPhpWind: function() {
if (window.winduid != undefined) return true;
return false
},
findObj: function(d) {
for (var i = 0; i < 10; i++) if ("object" == typeof d && typeof d.tagName != "undefined") {
var j = d.tagName.toLowerCase();
if ("a" == j || "area" == j) {
if (this.isIgnoreConvert(d)) break;
return d
}
if ("body" == j) break;
d = d.parentNode
} else break;
return null
},
analyseUrl: function(d) {
d = d.replace(/(^\s*)|(\s*$)/g, "").replace(/^http:\/\//g, "");
return this.urlFilter(d) ? "": /^([\w|\.|-]+\.qq|p\.tenxun|[\w|\.|-]+\.paipai)\.com/i.exec(d) ? "http://" + d: ""
},
urlFilter: function(d) {
var i;
for (i = this.whiteList.length; --i >= 0;) if (this.whiteList[i].exec(d)) return true;
return false
},
secondURI: function(d) {
d = d.replace(/(^\s*)|(\s*$)/g, "").replace(/^http:\/\//g, "");
if (this.urlFilter(d)) return "";
if (/(^|\?|&)[^&]*=([^&]+.paipai.com[^&]*)(\s|&|$)/i.test(d)) return unescape(RegExp.$2.replace(/\+/g,
" "));
return ""
},
foundAdd: function() {
var d = "&sitehash=" + this.userhash + "&winduid=" + this.member + "&windid=" + this.memberUid;
if (0 == this.inframe) d += "&from=" + encodeURIComponent(window.location.href);
else {
var i = this.referer();
this.isNull(i) || (d += "&from=" + encodeURIComponent(i))
}
if (this.isNull(this.getck("mac"))) {
this.setck("mac", this.hash);
this.mac = this.hash
} else this.mac = this.getck("mac");
d += "&mac=" + this.mac + "&py=" + this.py;
this.linkInfo = d
},
referer: function() {
var d = document.referrer;
if (!d) try {
if (window.opener) d =
window.opener.location.href
} catch(i) {}
return d
},
linkify: function(d) {
var i,
j;
if (d.nodeType == 3) {
i = d.data.search(/((https?)|(ftp))\:\/\/[^\s]*[^.,">\s\)\]]/);
if (i >= 0) {
i = d.splitText(i);
i.splitText(RegExp.lastMatch.length);
j = document.createElement("A");
j.href = i.data;
j.target = "_blank";
j.appendChild(i);
d.parentNode.insertBefore(j, d.nextSibling)
}
i = d.data.search(/www[^\s]*[^.,">\s\)\]]/);
if (i >= 0) {
i = d.splitText(i);
i.splitText(RegExp.lastMatch.length);
j = document.createElement("A");
j.href = "http://" + i.data;
j.target =
"_blank";
j.appendChild(i);
d.parentNode.insertBefore(j, d.nextSibling)
}
} else if (d.tagName != "STYLE" && d.tagName != "SCRIPT" && d.tagName != "A") for (i = 0; j = d.childNodes[i]; ++i) this.linkify(j)
},
hasClass: function(d, i) {
return d.className.indexOf(i) != -1
},
isIgnoreConvert: function(d) {
if (this.hasClass(d, this.ignore_class)) return true;
else if ("object" == typeof d.parentNode) return this.hasClass(d.parentNode, this.ignore_class)
},
loopFrames: function(d) {
for (var i = 0; i <= d.length; i++) try {
b = d.document.body;
b.normalize();
this.linkify(b)
} catch(j) {}
},
__main__: function() {
this.getWindid();
this.getWinduid();
this.inframe = window != parent;
this.foundAdd();
this._rewritePWchickUrl()
},
setck: function(d, i) {
var j = new Date,
l = (24 - j.getHours()) * 36E5;
j.setTime(j.getTime() + l);
document.cookie = d + "=" + escape(i) + ";expires=" + j.toGMTString()
},
getck: function(d) {
d = document.cookie.match(RegExp("(^| )" + d + "=([^;]*)(;|$)"));
if (d != null) return unescape(d[2]);
return null
},
getWindid: function() {
if (typeof window.windid != undefined) this.member = window.windid
},
getWinduid: function() {
if (typeof window.winduid !=
undefined) this.memberUid = window.winduid
},
_rewritePWchickUrl: function() {
var d = this;
if (this.isPhpWind() == true && typeof window.checkUrl == "function") {
var i = window.checkUrl;
window.checkUrl = function(j) {
var l = j.href,
k = d.analyseUrl(j.href);
if (1 < k.length) {
k = "http://" + d.host + "&to=" + encodeURIComponent(k) + d.linkInfo;
j.href = k
}
k = i(j);
j.href = l;
return k
}
}
},
chushi: function() {
return this
},
pwhash: function(d) {
if (!this.isNull(d)) this.userhash = d
},
creathash: function() {
var d = new Date,
i = d.getYear(),
j = d.getMonth() + 1,
l = d.getDate(),
k = d.getHours(),
n = d.getMinutes();
d = d.getSeconds();
i = i + "-" + j + "-" + l + " " + k + ":" + n + ":" + d + this.member + this.memberUid + this.userhash;
this.hash = i = this.hex_md5(i)
},
exchange: function() {
var d = this;
this.__main__();
document.onclick = function(i) {
try {
i = i || window.event;
var j = i.target || i.srcElement;
j = d.findObj(j);
if (null != j) {
var l = d.analyseUrl(j.href);
if (1 > l.length) {
l = d.secondURI(j.href);
if (1 > l.length) return
}
//http://"+a.host+"?app="+pid+"&urll="+c
var k = "http://" + host + "&urll=" + l ;
if (j.target == "_blank") {
var n = j.href;
setTimeout(function() {
j.href =
n
},
500)
}
j.href = k
}
} catch(a) {
return 1
}
}
},
setpy: function(d) {
if (!this.isNull(d)) this.py = d
}
};
解决方案 »
- 做一个新浪这样的黄道查询系统要多少钱啊?
- javascript控件的应用问题。
- 我通过javascript来控制一个图片的隐现,但图片的状态每变换一次,ie的垂直滚动条就自动到最上边去了,怎么办?
- 如何用传递一个表单的两个值?
- 关于在客户端变量和服务端变量
- 日期选择文本框无法输入的问题
- 求助<s:iterator>中的#L.index的用法问题
- onkeydown是否真的能够监听。。。
- 请问有没有办法改变<body>里面的属性值?
- 请问为什么我的图片加上热点之后,周围会有一圈蓝色边框呢
- 麻烦帮我分析下这段函数
- 菜鸟问题:javascript是把需要用到的js文件下载到本地执行,还是直接嵌入网页以文本的方式发送过来
在whiteList定义白名单即可解决