node-tutorial icon indicating copy to clipboard operation
node-tutorial copied to clipboard

脚本

Open Wscats opened this issue 8 years ago • 0 comments

假设日期是2013年6月5日早上6:00:00

setTimeout(function () { 
    $('.chatSend')[0].click();
 },(new Date(2013,5,4,5,0,0)-new Date()));

循环发送(每隔3秒发送一次):

setInterval(function(){$('.edit_area').html('需要发送的文字');
   $(".edit_area").trigger($.Event("keydown", { keyCode: 13,ctrlKey: true}));
   $('.btn_send').click();},3000);

定时发送(需注意日期格式)

setInterval(function(){
          if(new Date().toLocaleString().indexOf('2015/8/31 下午4:02:00')===0) 
             {$('.edit_area').html('需要发送的文字');
              $(".edit_area").trigger($.Event("keydown", { keyCode: 13,ctrlKey: true}));
              $('.btn_send').click();}},1000);

huajiao

setInterval(function(){
	$(".tt-type-msg").val("hello")
	$(".tt-type-submit").click()
},3000)

github

var i = 0;
for(;i<document.querySelectorAll("[aria-label='Star this repository']").length;i++){
	document.querySelectorAll("[aria-label='Star this repository']")[i].click()
}

获取评论并且去除空格

$($(".tt-msg-content-h5.tt-msg-content-h5-chat")[$(".tt-msg-content-h5.tt-msg-content-h5-chat").length-1]).text().replace(/(^\s*)|(\s*$)/g, "");
console.log("comments:" + $($(".tt-msg-content-h5.tt-msg-content-h5-chat")[$(".tt-msg-content-h5.tt-msg-content-h5-chat").length - 1]).text().replace(/(^\s*)|(\s*$)/g, ""))
		$.ajax({
			type: "GET",
			url: "http://localhost:81/angular/0317/turing.php",
			data: {
				qu: $($(".tt-msg-content-h5.tt-msg-content-h5-chat")[$(".tt-msg-content-h5.tt-msg-content-h5-chat").length - 1]).text().replace(/(^\s*)|(\s*$)/g, "")
			},
			success: function(data) {
				$(".tt-type-msg").val(JSON.parse(data).text)
			}
		})

终极版

console.log("comments:" + $($(".tt-msg-content-h5.tt-msg-content-h5-chat")[$(".tt-msg-content-h5.tt-msg-content-h5-chat").length - 1]).text().replace(/(^\s*)|(\s*$)/g, ""))
		$.ajax({
			type: "GET",
			url: "http://www.tuling123.com/openapi/api?key=c75ba576f50ddaa5fd2a87615d144ecf&info="+$($(".tt-msg-content-h5.tt-msg-content-h5-chat")[$(".tt-msg-content-h5.tt-msg-content-h5-chat").length - 1]).text().replace(/(^\s*)|(\s*$)/g, ""),
			success: function(data) {
                                console.log(data)
				$(".tt-type-msg").val(data.text)
				//$(".tt-type-submit").click()
			}
		})

chrome插件自动测评核心文件

let stu = {
	userid: "xxx",
	password: "xxx",
	commit: ["666", "特别帅", "特别厉害", "非常棒", "无与伦比", "亮瞎双眼", "特别厉害", "暂时没有", "nice", "知识面广,课余知识和课堂知识很丰富", "受益匪浅,值得钦佩", "good", "教课之外也教了很多工作经验", "优秀", "段子手", "通俗易懂", "生动活泼", "比较幽默", "讲话太快了", "再接再厉", "完美", "负责任,耐心讲解", "出其不意", "大神级别"]
}
let host = "";
let href = location.href.indexOf("?") ? location.href.split("?")[0] : location.href;

switch(href) {
	/*case `${host}/student.php/Public/login`:
		document.querySelector("[name='Account']").value = stu.userid;
		document.querySelector("[name='PassWord']").value = stu.password;
		setTimeout(() => {
			document.querySelector("[type='submit']").click();
		}, 500);
		break;*/
	case `${host}/student.php/Index/index`:
		location.href = `${host}/student.php/Index/evaluate`;
	case `${host}/student.php/Index/evaluate`:
		setTimeout(() => {
			document.querySelector("[class='btn btn-xs btn-success']").click()
		})
		break;
	case `${host}/student.php/Index/start_evaluate`:
		let i = 0;
		let inputs = document.querySelectorAll("input");
		for(; i < inputs.length;) {
			document.querySelectorAll("input")[i].click();
			i += 4;
		}
		document.querySelectorAll("textarea")[0].value = stu.commit[Math.floor(Math.random() * stu.commit.length)];
		document.querySelectorAll("textarea")[1].value = stu.commit[Math.floor(Math.random() * stu.commit.length)];
		document.getElementById("addstudent").click();
}

百度爬图

kapture 2018-12-20 at 10 11 33

let y = 0;
let num = 0;
let imgArr = [];
setInterval(()=>{
	let imgs = document.querySelectorAll("img");
	let length = imgs.length;
	if(num!==length){
		num = length;
		imgArr = imgs;
		console.log(length,imgArr);
	}
	y = y + 1;
	scrollTo(0,y);
},1)

微信自动回复

wechat

var num = 0;
setInterval(function(){
	// 监听每一条新的聊天记录
	var messages = document.querySelectorAll(".js_message_plain")
	// 获取信息的长度
	var length = messages.length
	// 这个if里面的逻辑是有新消息我才进行回复
	if(num!=length){
		//num和length不一样的话,打印新的消息
		console.log(messages[length-1].innerHTML)
		if(messages[length-1].innerHTML=='你好'){
			var appElement = document.querySelector('[ng-controller=chatSenderController]');
			var $scope = angular.element(appElement).scope();
			$scope.editAreaCtn = "你也好啊";
			$scope.sendTextMessage();
		}else if(messages[length-1].innerHTML=='今晚搞不搞'){
			var appElement = document.querySelector('[ng-controller=chatSenderController]');
			var $scope = angular.element(appElement).scope();
			$scope.editAreaCtn = "搞啊";
			$scope.sendTextMessage();
		}
		num = document.querySelectorAll(".js_message_plain").length
	}
},1000)

监听浏览器键盘事件

全局监听

document.onkeyup = function (e) {
    console.log(e.keyCode)
    e = e || window.event;
    e.preventDefault();
    console.log(e.keyCode);
    switch (e.keyCode) {
        case 38:
            console.log('上键');
            break;
        case 40:
            console.log('下键');
            break;
    }
}

监听页面所有的输入框

console.log("监听所有input输入框")
// 获取所有输入框节点
let inputs = document.querySelectorAll("input");
// 遍历所有input节点
[].forEach.call(inputs, (input) => {
    input.addEventListener("input", (e) => {
        // 打印输入的值
        console.log(e.target)
        console.log(e.data)
    })
});

鼠标右击事件

document.onmousedown = function (event) {
    var event = event || window.event
    if (event.button == "2") {
        //这里做处理
        console.log("点解鼠标右键",event)
        event.returnValue = false;
    };
} 

Wscats avatar Mar 19 '17 14:03 Wscats