scenexe.io AFK

press F, moves you back if too far from place where AFK was turned ON

当前为 2023-01-02 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        scenexe.io AFK
// @namespace   https://scnxwged.glitch.me/
// @description press F, moves you back if too far from place where AFK was turned ON
// @author      BZZZZ
// @include     /^https?\:\/\/scenexe\.io\/([?#]|$)/
// @include     /^https?\:\/\/new\-test\.scenexe\.io\/([?#]|$)/
// @include     /^https?\:\/\/test\.scenexe\.io\/([?#]|$)/
// @include     /^https?\:\/\/test2\.scenexe\.io\/([?#]|$)/
// @version     0.6
// @grant       none
// @run-at      document-start
// @inject-into content
// ==/UserScript==

(div=>{
div.setAttribute('onclick','"use strict";('+(()=>{
	//using strigified function to get syntax highlighting
	//constants
	var MAX_DISATANCE=100
	//code
	MAX_DISATANCE*=MAX_DISATANCE
	var log=console.log.bind(null,'%c[AFK]','font-weight:bold;color:#F0F;'),isFinite=Number.isFinite,init=get_gs=>{
		var decode=window.decode
		if(typeof decode!=='function'){
			log('error: window.decode is not function')
			return
		}
		var writef,f32a=new Float32Array(1),u8a=new Uint8Array(f32a.buffer),buf=Uint8Array.of(146,1,146,202,1,2,0,0,202,0,0,0,0)
		switch(new Uint16Array(buf.buffer,4,1)[0]){
			//detect byte order
			case 0x0102:
				log('big byte order detected')
				writef=off=>{
					if(isFinite(f32a[0])){
						buf[off]=u8a[0]
						buf[off+1]=u8a[1]
						buf[off+2]=u8a[2]
						buf[off+3]=u8a[3]
					}else{
						buf[off]=0
						buf[off+1]=0
						buf[off+2]=0
						buf[off+3]=0
					}
				}
				break
			case 0x0201:
				log('little byte order detected')
				writef=off=>{
					if(isFinite(f32a[0])){
						buf[off]=u8a[3]
						buf[off+1]=u8a[2]
						buf[off+2]=u8a[1]
						buf[off+3]=u8a[0]
					}else{
						buf[off]=0
						buf[off+1]=0
						buf[off+2]=0
						buf[off+3]=0
					}
				}
				break
			default:
				log('error: failed to detect byte order')
				return
		}
		var move_packet=(x,y)=>{
			f32a[0]=x
			writef(4)
			f32a[0]=y
			writef(9)
			return buf
		},afk=null,afk_off=()=>{
			afk.ws.removeEventListener('close',afk_off)
			afk.ws.removeEventListener('message',ws_onmessage)
			afk=null
			log('OFF')
		},afk_on=()=>{
			var ws=get_gs()
			if(!ws)return
			ws=ws.connection
			if(!ws||ws.readyState!==1)return
			afk={
				'x':null,
				'y':null,
				'tx':null,
				'ty':null,
				'was_moving':false,
				'ws':ws
			}
			ws.addEventListener('close',afk_off)
			ws.addEventListener('message',ws_onmessage)
			log('ON')
		},ws_onmessage=event=>{
			if(afk.ws.readyState!==1){
				afk_off()
				return
			}
			var data=new Uint8Array(event.data)
			//detect non-GAME_UPDATE packet without decoding
			if(data[0]!==146||data[1]!==204||data[2]!==100)return
			var player=decode(data)[1][0]
			if(!player){
				log("player doesn't exist")
				afk_off()
				return
			}
			if(typeof player[2]==='number')afk.x=player[2]
			if(typeof player[3]==='number')afk.y=player[3]
			if(afk.tx===null||afk.ty===null){
				afk.tx=afk.x
				afk.ty=afk.y
			}
			if(afk.x===null||afk.y===null)return
			var dx=afk.tx-afk.x,dy=afk.y-afk.ty
			if(dx*dx+dy*dy>MAX_DISATANCE){
				afk.was_moving=true
				afk.ws.send(move_packet(dx,dy))
			}else if(afk.was_moving){
				afk.was_moving=false
				afk.ws.send(move_packet(0,0))
			}
		}
		document.body.addEventListener('keyup',event=>{
			if(event.code!=='KeyF')return
			var ae=document.activeElement
			if(ae)switch(ae.tagName){
				case 'INPUT':
				case 'TEXTAREA':
					return
			}
			if(afk)afk_off()
			else afk_on()
		})
		log('loaded, gameSocket getter:',get_gs)
	},proxyobj={
		'__proto__':null,
		'apply':(targ,$this,args)=>{
			var getter
			if(args[1]==='gameSocket'&&(getter=args[2].get)){
				delete proxyobj.apply
				window.setTimeout(init,0,getter)
			}
			return Reflect.apply(targ,$this,args)
		}
	}
	Object.defineProperty=new Proxy(Object.defineProperty,proxyobj)
})+')()')
div.click()
})(document.createElementNS('http://www.w3.org/1999/xhtml','div'))