真的,不要用 js 权限在博客园刷粉、刷赞,虽然很容易。可是博客园开放了 js 权限是但愿咱们的我的博客能够更我的、更个性。说实话,你刷关注屁用没有,哪有人去看,刷赞却是有用,能够上首页推荐,不过文章写的不咋滴上去不是遭喷吗?本文就这两个功能随便聊聊技术上的问题。html
简单点的,能够写个对关注按钮的自动 click() 事件,不过博客园有一些 html 代码是后端分批次传输的,能够延迟等待加载完网页。ajax
有点难度的作法,能够写一段 ajax 脚本自动请求后端关注接口。示例代码以下:json
function GuanZhu() { if (typeof cb_blogUserGuid != "undefined") { var json = { "blogUserGuid": cb_blogUserGuid }; $.ajax({ type: "POST", url: "/mvc/Follow/FollowBlogger.aspx", data: JSON.stringify(json), contentType: "application/json; charset=utf-8", dataType: "text", success: function (data) { //过滤字符串 //window.confirm(data); //使用layer须要导包哦 console.log(data); } }); } }
这个的思路其实和刷关注的思路同样,示例代码以下:后端
var url = window.location.pathname.substring(1); var name = url.substring(0,url.indexOf('/')); $(function(){ var json ={"blogApp":name, "postId": cb_entryId , "voteType": "Digg", "isAbandoned": false}; $.ajax({ type: "POST", url: "/mvc/vote/VoteBlogPost.aspx", data: JSON.stringify(json), contentType: "application/json; charset=utf-8", dataType: "json", success: function(data) { if (data.IsSuccess) { // ok } } }); });
本文的观点很支棱,不支持刷赞刷关注!mvc