首页 > Essays > Documentary > 刷楼插件大成功
2015
01-15

刷楼插件大成功

来了狼厂3个月,JS终于入门,现在可以自动填写评论了~这样很快就能刷出一个小度路由啦~Yeah

window.onload =ii;

function ii() {

var lp = location.pathname;
// var btn = document.getElementById(“submitButton”);

//btn.addEventListener(“mouseover”, cl0, true);
if (lp == “/portal/newsDetail”) {
//alert(“PortalNews”);
var portNews = document.getElementsByClassName(“readMoreComments”)[0];
portNews.addEventListener(“mouseover”, cl1, true);
} else if (lp == “/core/index.jsp”) {
//alert(“Core”);
var iaru = document.getElementsByClassName(“pdt_formBtn”)[0].childNodes[1];
iaru.addEventListener(“mouseover”, cl0, true);
} else if (lp == “/portal/pagedetail”) {
//alert(“PortalPages”);
var portNews = document.getElementsByClassName(“readMoreComments”)[0];
portNews.addEventListener(“mouseover”, cl1, true);
} else {
//alert(“None”);
}

//document.getElementById(“submitButton”).onmouseover = ac;

function cl0() {
var lg = document.getElementsByClassName(“pdt_content”).length;

var ra = Math.floor(Math.random() * lg);

var sh = document.getElementsByClassName(“pdt_content”)[ra].innerHTML;

var ar = [“顶顶”, “赞”, “支持”, “顶顶赞”, “支持顶一顶”, “”, “狂顶赞”];

var ra2 = Math.floor(Math.random() * ar.length);

document.getElementById(“commentContent”).innerHTML = ar[ra2] + sh;
//setTimeout(cl, 1000);
}

function cl1() {
var lg = document.getElementsByClassName(“comments”)[0].getElementsByClassName(“content”).length;

var ra = Math.floor(Math.random() * lg);

var sh = document.getElementsByClassName(“comments”)[0].getElementsByClassName(“content”)[ra].innerHTML;

var ar = [“顶顶”, “赞”, “支持”, “顶顶赞”, “支持顶一顶”, “”, “狂顶赞”];

var ra2 = Math.floor(Math.random() * ar.length);

shtrim = Trim(sh)

document.getElementById(“J_commentFormTextarea”).innerHTML = ar[ra2] + shtrim;
//setTimeout(cl, 1000);
}

}

function Trim(str) {
var result;
result = str.replace(/^\s+|\s+$/g, ”); //网上有一个好像是没转义
return result;
}

三年后的重构

 

最后编辑:
作者:scplay
这个作者貌似有点懒,什么都没有留下。

刷楼插件大成功》有 1 条评论

  1. scplay 说:

    缩进很飘逸,变量命名很规律都是2个英文

scplay的回复 取消回复

你的email不会被公开。