Skip to content

Commit

Permalink
Fixes for useragents
Browse files Browse the repository at this point in the history
  • Loading branch information
sefinek24 committed Dec 18, 2023
1 parent 0fc9842 commit c28a8ca
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
24 changes: 12 additions & 12 deletions scripts/useragent/get-ua.js
Expand Up @@ -10,25 +10,25 @@ const userAgents = [
secChUaPlatform: '"Windows"',
secChUaPlatformVersion: '"10.0.0"',
},

// Windows - Firefox
{
agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0',
secChUa: '"Firefox";v="120", "Gecko";v="20100101", "Windows";v="10"',
secChUaPlatform: '"Windows"',
},

// MacOS - Chrome
{
agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
secChUa: '"Google Chrome";v="120", "Chromium";v="120", "Mac OS X";v="14.1"',
secChUaPlatform: '"macOS"',
},
// {
// agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
// secChUa: '"Google Chrome";v="120", "Chromium";v="120", "Mac OS X";v="14.1"',
// secChUaPlatform: '"macOS"',
// },

// MacOS - Firefox
{
agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14.1; rv:120.0) Gecko/20100101 Firefox/120.0',
secChUa: '"Firefox";v="120", "Gecko";v="20100101", "Mac OS X";v="14.1"',
secChUaPlatform: '"macOS"',
},
// {
// agent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 14.1; rv:120.0) Gecko/20100101 Firefox/120.0',
// secChUa: '"Firefox";v="120", "Gecko";v="20100101", "Mac OS X";v="14.1"',
// secChUaPlatform: '"macOS"',
// },
];

module.exports = () => {
Expand Down
13 changes: 12 additions & 1 deletion scripts/useragent/object.js
Expand Up @@ -29,4 +29,15 @@ const DEFAULT_HEADERS = {
'User-Agent': userAgent,
};

module.exports = DEFAULT_HEADERS;

function getValidHeaders(headers) {
return Object.fromEntries(
Object.entries(headers).filter(
([, value]) => value !== undefined && value !== null,
),
);
}

console.log(getValidHeaders(DEFAULT_HEADERS));

module.exports = getValidHeaders(DEFAULT_HEADERS);

0 comments on commit c28a8ca

Please sign in to comment.