mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-02-23 15:19:35 +02:00
better User-Agent randomization 🐛
This commit is contained in:
parent
ffc392b66b
commit
ae31807eb7
1 changed files with 6 additions and 1 deletions
|
@ -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: {}
|
||||
})
|
||||
|
|
Loading…
Add table
Reference in a new issue