js实现csdn一键二连
本脚本内容仅供学习,禁止用于一切非法目的,否则后果自负。
(function(){
var li = document.createElement('li');
li.setAttribute("class","tool-item");
var a = document.createElement('a');
a.innerHTML = "一键二连";
a.setAttribute("id","一键二连");
a.setAttribute("class","company active");
var msg=document.getElementsByClassName("toolbox-list")[0];
msg.appendChild(li);
li.appendChild(a);
$("#一键二连").on({
mouseover: function() {
$(this).is(".active") && ($(".triplet-prompt img.close-prompt").css("display", "none"), $(".triplet-prompt").css("width", "300px"), $(".triplet-prompt").fadeIn(500))
},
mouseout: function() {
$(".triplet-prompt").fadeOut(500)
}
})
function 点赞ajax(t) {//n(t)
getCookie("UserName") ? $.ajax({
url: blogUrl + "/phoenix/web/v1/article/like",
type: "post",
dataType: "json",
data: {
articleId: articleId
},
xhrFields: {
withCredentials: !0
},
success: function(t) {
if (200 == t.code) {
if (t.data.status) $("#is-like-img").hide(),
$("#is-like-imgactive").show(),
$("#is-like-span").text("已赞"),
$("#is-like-span")[0].style = "color:#fc5531 !important;",
$("#spanCount")[0].style = "color:#fc5531 !important;";
else {
$("#is-like-imgactive").hide(),
$("#is-like-img").show(),
$("#is-like-span").text("点赞");
var e = "color:#555666 !important;";
"Black" === skinStatus && (e = "color:#ccccd8 !important;"),
$("#is-like-span")[0].style = e,
$("#spanCount")[0].style = e;
}
$("#spanCount").text(t.data.like_num > 0 ? t.data.like_num: "")
} else i函数(!1, t.message);
判断();
}
}) : window.csdn.loginBox.show()
}
function i函数(t, e) {//function i(t, e)
if (x.skinBoxshadow.html(""), t) {
var o = '<div class="reward-success reward-tip"> <svg t="1513153231313" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="4182" id="mx_n_1513153231314" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><defs><style type="text/css"></style></defs><path d="M512 0C228.8 0 0 228.8 0 512s228.8 512 512 512 512-228.8 512-512S795.2 0 512 0z m244.8 392L467.2 691.2c-8 9.6-24 12.8-36.8 12.8-12.8 0-27.2-3.2-36.8-12.8L267.2 560c-16-16-16-43.2 0-59.2s41.6-16 57.6 0l105.6 110.4 267.2-278.4c16-16 41.6-16 57.6 0s16 43.2 1.6 59.2z" p-id="4183" fill=""></path></svg> <span>' + e + "</span></div>";
x.skinBoxshadow.append(o)
} else {
var i = '<div class="reward-error reward-tip"> <svg t="1513590447537" class="icon" style="" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9504" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><defs><style type="text/css"></style></defs><path d="M512 0C228.8 0 0 228.8 0 512s228.8 512 512 512 512-228.8 512-512S795.2 0 512 0z m0 832c-35.2 0-64-28.8-64-64s28.8-64 64-64 64 28.8 64 64-28.8 64-64 64z m64-320c0 35.2-28.8 64-64 64s-64-28.8-64-64V256c0-35.2 28.8-64 64-64s64 28.8 64 64v256z" p-id="9505" fill=""></path></svg> <span>' + e + "</span></div>";
x.skinBoxshadow.append(i)
}
x.skinBoxshadow.fadeIn(200),
setTimeout(function() {
x.skinBoxshadow.fadeOut(200),
x.skinBoxshadow.html("")
},
1500)
}
var x = {
rewardItem: $("#toolreward"),
rewardBox: $("#reward"),
skinBoxshadow: $(".skin-boxshadow"),
isHaveMoney: $("#reward .is-have-money"),
coinNum: 0,
moneyNum: 0,
coinNumInit: 5,
rewardShowMore: $(".reward-user-box"),
rewardBtCoin: $(".change-bt-box")
};
function 收藏ajax() {//a()
window.csdn.userLogin.loadAjax(function(t) {
$.ajax({
url: blogUrl + "/phoenix/web/v1/collect",
dataType: "json",
type: "POST",
xhrFields: {
withCredentials: !0
},
data: {
articleId: articleId
},
success: function(t) {
200 === t.code && 收藏(t.data.status)
},
error: function() {}
})
})
}
function 收藏(t) {//s(t)
t ? ($("#is-collection-imgactive").show(), $("#is-collection-img").hide(), $("#is-collection").text("已收藏"), $("#blog_detail_zk_collection .un-collect-status").hide(), $("#blog_detail_zk_collection .collect-status").show(), $("#blog_detail_zk_collection span.name").text("已收藏"), ($(".get-collection").text() ? $(".get-collection").text(1 * $("#get-collection").text() + 1) : $(".get-collection").text("1"))) : ($("#is-collection-imgactive").hide(), $("#is-collection-img").show(), $("#is-collection").text("收藏"), $("#blog_detail_zk_collection .un-collect-status").show(), $("#blog_detail_zk_collection .collect-status").hide(), $("#blog_detail_zk_collection span.name").text("收藏"), $(".get-collection").text() ? 1 * $("#get-collection").text() - 1 <= 0 ? $(".get-collection").text("") : $(".get-collection").text(1 * $("#get-collection").text() - 1) : $(".get-collection").text("")),
判断()
}
function 判断() {//h()
"block" === $("#is-like-imgactive").css("display") && "block" === $("#is-collection-imgactive").css("display") ? $("#一键二连").removeClass("active"): $("#一键二连").addClass("active")
}
$("#一键二连").on("click",
function() {
$(this).hasClass("active") && ("block" == $("#is-like-img").css("display") && 点赞ajax(), "block" == $("#is-collection-img").css("display") && 收藏ajax(),
$("#is-collection-img-collection").show().addClass("active-animation"),
setTimeout(function() {
$("#is-collection-img-collection").hide().removeClass("active-animation")
},
800))
判断();
});
})();
效果图如下(我已经点击一键二连)