mirror of
https://gitea.invidious.io/iv-org/invidious-copy-2022-04-11.git
synced 2024-08-15 00:43:26 +00:00
Move hardcoded user agents to user-agents.json
This commit is contained in:
parent
5af594bf0f
commit
71ec829c33
2 changed files with 17 additions and 20 deletions
14
config/user-agents.json
Normal file
14
config/user-agents.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"safari": {
|
||||
"os": ["Macintosh; Intel Mac OS X 10_15_7", "Macintosh; Intel Mac OS X 10_15_6",
|
||||
"Macintosh; Intel Mac OS X 11_3", ""],
|
||||
"versions": ["14.1.1", "14.1", "14.0.3"]
|
||||
},
|
||||
|
||||
"firefox": {
|
||||
"os": ["Macintosh; Intel Mac OS X 10.15'", "Macintosh; Intel Mac OS X 10.14",
|
||||
"Windows NT 10.0; Win64; x64", "X11; Ubuntu; Linux x86_64",
|
||||
"X11; Linux x86_64", "Windows NT 10.0", "Macintosh; Intel Mac OS X 11.3"],
|
||||
"versions": ["88.0 ", "89.0", "90.0", "78.0"]
|
||||
}
|
||||
}
|
|
@ -1,26 +1,9 @@
|
|||
# Using different browsers would allow us to disguise our traffic even more.
|
||||
# However, due to the widely different version and operating system values as well as
|
||||
# their frequency on different OSes we're going to need a separate dataset
|
||||
# for everything.
|
||||
|
||||
AGENT_COMPONENTS = {
|
||||
"safari" => {
|
||||
"os" => ["Macintosh; Intel Mac OS X 10_15_7", "Macintosh; Intel Mac OS X 10_15_6"],
|
||||
"versions" => ["14.1.1", "14.1", "14.0.3"],
|
||||
},
|
||||
|
||||
"firefox" => {
|
||||
"os" => ["Macintosh; Intel Mac OS X 10.15'", "Macintosh; Intel Mac OS X 10.14",
|
||||
"Windows NT 10.0; Win64; x64", "X11; Ubuntu; Linux x86_64",
|
||||
"X11; Linux x86_64"],
|
||||
"versions" => ["88.0 ", "89.0"],
|
||||
},
|
||||
}
|
||||
AGENT_COMPONENTS = JSON.parse(File.read("config/user-agents.json")).as_h
|
||||
|
||||
private def generate_user_agent
|
||||
agent_component = AGENT_COMPONENTS.keys.sample(1)[0]
|
||||
os = AGENT_COMPONENTS[agent_component]["os"].sample(1)[0]
|
||||
version = AGENT_COMPONENTS[agent_component]["versions"].sample(1)[0]
|
||||
os = AGENT_COMPONENTS[agent_component]["os"].as_a.sample(1)[0]
|
||||
version = AGENT_COMPONENTS[agent_component]["versions"].as_a.sample(1)[0]
|
||||
base = "Mozilla/5.0 "
|
||||
|
||||
case agent_component
|
||||
|
|
Loading…
Reference in a new issue