首页 新闻 搜索 专区 学院

帮忙大概解释下这段代码是什么意思。。。。最主要的是 不会这个写法。。。

0
[待解决问题]

!function() {
var i, prefix, userInfo, shareInfo, query, h6app_userInfo, h6app_shareInfo, userInfo_config = window.userInfo_config || {},
config = {
prefix: "h6",
ssoUrl: "**********",
appid: "*********",
scope: "snsapi_base",
getUnionid: !1,
version: "1_1_0",
shareInfoKey: "shareInfo",
ssoClean: !0,
shareClean: !1,
wxOut: !0,
timeout: 828e5,
saveAs: ""
};
for (i in userInfo_config) config[i] = userInfo_config[i];
prefix = config.prefix, userInfo = {}, shareInfo = {}, query = {
get: function(a, b) {
var c = new RegExp("(^|&)" + a + "=([^&]*)(&|$)", "i"),
d = location.search.substr(1).match(c);
return b && (d = (b.split("#")[0].split("?")[1] || "").match(c)), d ? decodeURIComponent(d[2]) : null
},
set: function(a, b, c) {
return this.change(c || location.href, a, b)
},
del: function(a, b) {
return this.delete(a, b)
},
change: function(url, name, val) {
var tmp, pattern = name + "=([^&]*)",
replaceText = name + "=" + val,
hash = 2 === url.split("#").length ? "#" + url.split("#")[1] : "";
return url = url.split("#")[0], url.match(pattern) ? (tmp = "/(" + name + "=)([^&]*)/gi", tmp = url.replace(eval(tmp), replaceText), tmp + hash) : url.match("[?]") ? url + "&" + replaceText + hash : url + "?" + replaceText + hash
},
"delete": function(a, b) {
var h, i, c = {},
d = b || location.href,
e = d.split("#")[0].split("?"),
f = e[0],
g = 2 === d.split("#").length ? "#" + d.split("#")[1] : "";
if (e[1] && 0 < e[1].length) {
e = e[1].split("&");
for (h in e) i = e[h].split("="), c[i[0]] = i[1]
}
a && delete c[a];
for (h in c) e = "&", f.match("[?]") || (e = "?"), f += e + h + "=" + c[h];
return f + g
}
}, h6app_userInfo = {
localStorageKeyName: "h6app_userInfo_" + config.saveAs + config.version,
get: function() {
var b, c, d, a = h6app_userInfo.localStorageKeyName;
query.get(prefix + "openid") && query.get(prefix + "s") && query.get(prefix + "t") ? !query.get(prefix + "unionid") && config.getUnionid ? (config.scope = "snsapi_userinfo", h6app_userInfo.reinit()) : (userInfo = {
openid: query.get(prefix + "openid"),
s: query.get(prefix + "s"),
unionid: query.get(prefix + "unionid"),
sign_time: query.get(prefix + "t"),
sign: query.get(prefix + "sign"),
nickname: query.get(prefix + "nickname"),
headimgurl: query.get(prefix + "headimgurl"),
sex: query.get(prefix + "sex"),
city: query.get(prefix + "city"),
country: query.get(prefix + "country"),
province: query.get(prefix + "province")
}, localStorage.setItem(a, JSON.stringify(userInfo)), (config.ssoClean || config.shareClean && query.get(config.shareInfoKey)) && (config.ssoClean && (b = location.href.toString(), b = query.del(prefix + "openid", b), b = query.del(prefix + "s", b), b = query.del(prefix + "unionid", b), b = query.del(prefix + "t", b), b = query.del(prefix + "sign", b), b = query.del(prefix + "token", b), b = query.del(prefix + "state", b), b = query.del(prefix + "nickname", b), b = query.del(prefix + "headimgurl", b), b = query.del(prefix + "sex", b), b = query.del(prefix + "country", b), b = query.del(prefix + "province", b), b = query.del(prefix + "city", b)), config.shareClean && query.get(config.shareInfoKey), b && (b = query.del(query.del(config.shareInfoKey), b)), location.replace(b))) : query.get(prefix + "openid", document.referrer) && query.get(prefix + "s", document.referrer) && query.get(prefix + "t", document.referrer) ? !query.get(prefix + "unionid", document.referrer) && config.getUnionid ? (config.scope = "snsapi_userinfo", h6app_userInfo.reinit()) : (userInfo = {
openid: query.get(prefix + "openid", document.referrer),
s: query.get(prefix + "s", document.referrer),
unionid: query.get(prefix + "unionid", document.referrer),
sign_time: query.get(prefix + "t", document.referrer),
sign: query.get(prefix + "sign", document.referrer),
nickname: query.get(prefix + "nickname", document.referrer),
headimgurl: query.get(prefix + "headimgurl", document.referrer),
sex: query.get(prefix + "sex", document.referrer),
city: query.get(prefix + "city", document.referrer),
country: query.get(prefix + "country", document.referrer),
province: query.get(prefix + "province", document.referrer)
}, localStorage.setItem(a, JSON.stringify(userInfo)), config.shareClean && query.get(config.shareInfoKey) && location.replace(query.del(config.shareInfoKey))) : localStorage.getItem(a) && localStorage.getItem(a).length > 90 ? (userInfo = JSON.parse(localStorage.getItem(a)), c = 1e3 * userInfo.sign_time, d = (new Date).getTime(), d - c > config.timeout ? (localStorage.removeItem(a), userInfo = {}, h6app_userInfo.reinit()) : config.shareClean && query.get(config.shareInfoKey) && location.replace(query.del(config.shareInfoKey))) : h6app_userInfo.reinit()
},
reinit: function() {
var b, a = navigator.userAgent.toLowerCase();
console.log(config), (a.match(/MicroMessenger/i) || !config.wxOut) && (b = config.ssoUrl + "?redirect_uri=" + encodeURIComponent(query.del(config.shareInfoKey)) + "&scope=" + config.scope + "&state=&appid=" + config.appid + "&prefix=" + prefix, window.location.replace(b))
}
}, h6app_shareInfo = {
get: function() {
var a = query.get(config.shareInfoKey);
if (a ? sessionStorage.setItem(config.shareInfoKey, a) : sessionStorage.getItem(config.shareInfoKey) && (a = sessionStorage.getItem(config.shareInfoKey)), a && a.length) try {
shareInfo = JSON.parse(a)
} catch (b) {
shareInfo = null
} else shareInfo = null;
h6app_userInfo.get()
}
}, h6app_shareInfo.get(), window.h6app_query = query, window.h6app_userInfo = userInfo, window.h6app_shareInfo = shareInfo
}();

问题补充:

比如我百度了  !function(){}();是立即执行  是啥意思。。。

 

但是类似 

prefix = config.prefix, userInfo = {}, shareInfo = {}, query = {
get: function(a, b) {
var c = new RegExp("(^|&)" + a + "=([^&]*)(&|$)", "i"),
d = location.search.substr(1).match(c);
return b && (d = (b.split("#")[0].split("?")[1] || "").match(c)), d ? decodeURIComponent(d[2]) : null
},
set: function(a, b, c) {
return this.change(c || location.href, a, b)
},
del: function(a, b) {
return this.delete(a, b)
},
change: function(url, name, val) {
var tmp, pattern = name + "=([^&]*)",
replaceText = name + "=" + val,
hash = 2 === url.split("#").length ? "#" + url.split("#")[1] : "";
return url = url.split("#")[0], url.match(pattern) ? (tmp = "/(" + name + "=)([^&]*)/gi", tmp = url.replace(eval(tmp), replaceText), tmp + hash) : url.match("[?]") ? url + "&" + replaceText + hash : url + "?" + replaceText + hash
},
"delete": function(a, b) {
var h, i, c = {},
d = b || location.href,
e = d.split("#")[0].split("?"),
f = e[0],
g = 2 === d.split("#").length ? "#" + d.split("#")[1] : "";
if (e[1] && 0 < e[1].length) {
e = e[1].split("&");
for (h in e) i = e[h].split("="), c[i[0]] = i[1]
}
a && delete c[a];
for (h in c) e = "&", f.match("[?]") || (e = "?"), f += e + h + "=" + c[h];
return f + g
}
}   我就不明白了。

五百万的主页 五百万 | 初学一级 | 园豆:83
提问于:2017-05-07 03:23
< >
分享
所有回答(1)
0

就是js文件一加载就执行

狼爷 | 园豆:1202 (小虾三级) | 2017-05-07 15:52
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册