Created
November 5, 2018 02:17
-
-
Save RayBB/2aef69a5f6d33e68fd4bf6e1627430c7 to your computer and use it in GitHub Desktop.
Automatically clicks stuff for the OnePlus clicker contest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const socket = new WebSocket('wss://socket-unlock.oneplus.com/socket.io/?EIO=3&transport=websocket'); | |
const username = "raybb" | |
let curCounter = 420; | |
let messagesSent = 0; | |
let messagesToSend = 10000; | |
let maxMessageDelayMS = 500; | |
// Connection opened | |
socket.addEventListener('open', function (event) { | |
console.log("opened"); | |
socket.send('420["authenticate user",{"username":"' + username + '","token":"ff45fb994e3124a5e0ce7bf7f27745dcbe62e71275532f982498b798","squad":"","locale":"en-gb","count":100000,"csrf":"0xsn5yq9SAb65OvTXDl3OjzRoVPgr1zVvDtzoVR4ZhjdptbHClRSVaSJDXKwXy8b"}]'); | |
}); | |
// Listen for messages | |
socket.addEventListener('message', function (event) { | |
if(event.data.indexOf(username) > -1){ | |
console.log('Message from server ', event.data); | |
if (event.data.indexOf("430") > -1){ | |
startSending(); | |
} | |
} | |
}); | |
function startSending(){ | |
if (messagesSent == messagesToSend) return; | |
if (messagesSent%100 == 0) console.log("Messages sent: " + messagesSent); | |
let delay = send100(); | |
setTimeout(function(){startSending()}, delay); | |
} | |
function send100(){ | |
let times = []; | |
let total = 0; | |
for (let i = 0; i < 100; i++){ | |
let random = Math.random() * maxMessageDelayMS; | |
total += random; | |
times[i] = total; | |
setTimeout(function(){socket.send(generateMessage());messagesSent++;}, times[i]); | |
} | |
console.log(times); | |
return total; | |
} | |
function getTapCounter(){ | |
if (curCounter.toString().search(/^430/) == 0){ | |
curCounter = parseInt("421" + curCounter.toString().match(/0+/)[0]); | |
} else { | |
curCounter++; | |
} | |
return curCounter; | |
} | |
function generateMessage(){ | |
let msg = getTapCounter() + '["tap_logs",{"username":' + username + ',"timestamp":' + | |
getTimeStamp() + ',"touchX":' + getX() + ',"touchY":' + getY() + '}]'; | |
console.log(msg); | |
return msg; | |
} | |
function getTimeStamp(){ | |
return Math.round((new Date()).getTime() / 1000); | |
} | |
function getX(){ | |
return Math.floor(Math.random() * 389) + 19; | |
} | |
function getY(){ | |
return Math.floor(Math.random() * 737) + 78; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment