Discord聊天室私聊脚本

1,517 次浏览次阅读
var yuju="test msg"; // 语句修改
var suiji=true;		// 是否加随机字符
var NameArry=new Array();
var scrolls=1580;
var scrollstep=800;
var step=0;
var memberIndex=0;
var t=0;
var membercolor="rgb(185, 187, 190)";
t=setInterval(sendstr,2000);
function sendstr(){
var temscroll=scrolls+scrollstep*step;
console.log("当前 scrolls:"+temscroll);
console.log("当前 memberIndex:"+memberIndex);
var memberOnline=$('div[class^="memberOnline"]');
console.log("memberOline:"+memberOnline.length);
if (memberOnline.length<1)
{return;}
if (t>0){clearInterval(t);
	t=0;
	$('div[class^="scroller-"]').eq(3).scrollTop(scrolls+scrollstep*step);
	setTimeout(sendstr,3000);
}
var color=memberOnline.eq(memberIndex).find('div[class^="nameTag"]').eq(0).css('color');
var name=memberOnline.eq(memberIndex).find('span[class^="usernameOnline"]').eq(0).html();
while(color!=membercolor || NameArry.indexOf(name)>0 || typeof(name)=="undefined") {
	memberIndex++;
	if (memberIndex<memberOnline.lengt){color=memberOnline.eq(memberIndex).find('div[class^="nameTag"]').eq(0).css('color');
		name=memberOnline.eq(memberIndex).find('span[class^="usernameOnline"]').eq(0).html();}else{break;}
	//console.log(name);
}
if (color!=membercolor || NameArry.indexOf(name)>0){if ($('div[class^="scroller-"]').eq(3).find('div[style^="width: 100%;"]').eq(1).css('height')=="0px")
	{step=0;}
	else{step++;}
	$('div[class^="scroller-"]').eq(3).scrollTop(scrolls+scrollstep*step);
	setTimeout(sendstr,3000);
}
//console.log(NameArry);
console.log("正在发消息给:"+name);
NameArry.push(name);

memberOnline.eq(memberIndex).click();
var str=yuju;
if (suiji){str=str+'-('+Math.random().toString(36).substr(2)+')';
}
$('input[class^="quickMessage"]').val(str);
fireKeyEvent($('input[class^="quickMessage"]')[0], 'keypress', 13);
setTimeout(continuesend,3000);
}

function continuesend(){console.log("正在返回页面...");
	$('a[aria-label="RuneScape"]').find('div').click();
	t=setInterval(sendstr,2000);
}

function fireKeyEvent(el,evtType,keyCode){var doc=el.ownerDocument,win=doc.defaultView||doc.parentWindow,evtObj;if(doc.createEvent){if(win.KeyEvent){evtObj=doc.createEvent('KeyEvents');evtObj.initKeyEvent(evtType,true,true,win,false,false,false,false,keyCode,0)}else{evtObj=doc.createEvent('UIEvents');Object.defineProperty(evtObj,'keyCode',{get:function(){return this.keyCodeVal}});Object.defineProperty(evtObj,'which',{get:function(){return this.keyCodeVal}});evtObj.initUIEvent(evtType,true,true,win,1);evtObj.keyCodeVal=keyCode;if(evtObj.keyCode!==keyCode){console.log("keyCode"+evtObj.keyCode+"和 ("+evtObj.which+") 不匹配")}}el.dispatchEvent(evtObj)}else if(doc.createEventObject){evtObj=doc.createEventObject();evtObj.keyCode=keyCode;el.fireEvent('on'+evtType,evtObj)}}
正文完
 0
yxsoft
版权声明:本站原创文章,由 yxsoft 于2019-04-15发表,共计2582字。
转载说明:除特殊说明外本站文章皆由YXSoft发布,转载请注明出处。