better User-Agent randomization 🐛

This commit is contained in:
Jannis R 2018-08-08 18:40:35 +02:00
parent ffc392b66b
commit ae31807eb7
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -19,6 +19,11 @@ try {
process.exit(1)
}
const randomizeUserAgent = (userAgent) => {
const i = Math.round(Math.random() * userAgent.length)
return userAgent.slice(0, i) + id + userAgent.slice(i)
}
const md5 = input => createHash('md5').update(input).digest()
const request = (profile, userAgent, opt, data) => {
@ -34,7 +39,7 @@ const request = (profile, userAgent, opt, data) => {
'Content-Type': 'application/json',
'Accept-Encoding': 'gzip, deflate',
'Accept': 'application/json',
'user-agent': id + ' ' + userAgent
'user-agent': randomizeUserAgent(userAgent)
},
query: {}
})