千峰培训_前端_day04_js与斗鱼机器人

首先是0-100的猜数字游戏,代码如下:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>0-100猜数字游戏</title>
	</head>
	<body>
		<h1>0-100猜数字游戏</h1>
		<input type="text" id="txt" value="" placeholder="0-100猜数字游戏" />
		<button id='btn'>确定</button>
	</body>
	<script type="text/javascript">
		/*定义答案*/
		var num=Math.round(Math.random()*100);
		/*查找元素*/
		var textnum=document.getElementById('txt');
		var btn=document.getElementById('btn');
		/*点击确定按钮时判断*/
		btn.onclick=function(){				
			/*获取输入内容*/
			var textnum2=textnum.value;
			/*输入的值比答案大,提示输入值太大了*/
			if(textnum2>num)
			{
				alert('太大');
			}
			/*输入的值比答案小,提示输入值 太小了*/
			else if(textnum2<num)
			{
				alert('太小');
			}
			/*答案正确*/
			else
			{
				alert('答案正确');
			}					
		}
		
	</script>
</html>

然后是斗鱼直播平台的自动评论机器人,代码如下:

setInterval(function(){document.querySelector('.ChatSend-txt').value='小姐姐你真好看,我要给你生猴子'+Math.round(Math.random()*10);document.querySelector('.ChatSend-button ').click()},1000)

停止的函数是 clearInterval 函数。

最后是微信网页版定时发送消息:

var appElement = document.querySelector('[ng-controller=chatSenderController]');
var $scope = angular.element(appElement).scope();
$scope.editAreaCtn = "今晚搞不搞";
$scope.sendTextMessage();
undefined
setInterval(function(){$scope.editAreaCtn = "今晚搞不搞";
$scope.sendTextMessage();},5000)
发布了32 篇原创文章 · 获赞 18 · 访问量 6559

猜你喜欢

转载自blog.csdn.net/mm13420109325/article/details/85338644