mirror of
https://github.com/YuzuZensai/play-dl-test.git
synced 2026-01-06 04:32:40 +00:00
Add workflow to update the user agents once a month
This commit is contained in:
19
.github/updateUserAgents.js
vendored
Normal file
19
.github/updateUserAgents.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
const { writeFileSync } = require('fs');
|
||||
const UserAgent = require('user-agents');
|
||||
|
||||
const generator = new UserAgent({ deviceCategory: 'desktop' });
|
||||
const userAgents = [];
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
let userAgent = generator.random();
|
||||
|
||||
// only use Windows and Linux user agents and exclude Internet Explorer ones
|
||||
while (!(userAgent.data.platform.startsWith('Win') || userAgent.data.platform.startsWith('Linux'))
|
||||
|| userAgent.data.userAgent.includes('; MSIE') || userAgent.data.userAgent.includes('Trident/')) {
|
||||
userAgent = generator.random();
|
||||
}
|
||||
|
||||
userAgents.push(userAgent.toString());
|
||||
}
|
||||
|
||||
writeFileSync('play-dl/Request/useragents.json', JSON.stringify(userAgents, null, 4));
|
||||
Reference in New Issue
Block a user