// ==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\/([?#]|$)/
// @version 0.1
// @grant none
// @run-at document-start
// @inject-into content
// ==/UserScript==
(div=>{
div.setAttribute('onclick','"use strict";Reflect.apply('+(()=>{
//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;'),init=get_ws=>{
var decode=window.decode
if(typeof decode!=='function'){
log('error: window.decode is not function')
return
}
var buf=Uint8Array.of(146,1,146,203,0,0,0,0,0,0,0,0,203,0,0,0,0,0,0,0,0).buffer,bufview=new DataView(buf),move_packet=(x,y)=>{
bufview.setFloat64(4,x,false)
bufview.setFloat64(13,y,false)
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_ws()
if(!ws||ws.forcedClosed||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.forcedClosed||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&&ae.tagName==='INPUT')return
if(afk)afk_off()
else afk_on()
})
},proxyobj={
'__proto__':null,
'apply':(targ,$this,args)=>{
var getter
if(args[1]==='socket'&&(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)
})+',null,[])')
div.click()
})(document.createElementNS('http://www.w3.org/1999/xhtml','div'))