Add Modrinth App to app user agent string (#6084)

* Add Modrinth App to app user agent string

* Simplify UA brand strings
This commit is contained in:
aecsocket
2026-05-12 16:23:33 +01:00
committed by GitHub
parent 1ddbae40b7
commit f5462b6dd8

View File

@@ -17,7 +17,15 @@ pub struct AdsState {
const AD_LINK: &str = "https://modrinth.com/wrapper/app-ads-cookie"; const AD_LINK: &str = "https://modrinth.com/wrapper/app-ads-cookie";
#[cfg(not(target_os = "linux"))] #[cfg(not(target_os = "linux"))]
const ADS_USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36"; const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
#[cfg(not(target_os = "linux"))]
const ADS_USER_AGENT: &str = concat!(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 ",
"(KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 ",
"ModrinthApp/",
APP_VERSION,
" (Modrinth App)",
);
#[cfg(windows)] #[cfg(windows)]
fn ads_user_agent_override_params() -> String { fn ads_user_agent_override_params() -> String {
@@ -28,12 +36,14 @@ fn ads_user_agent_override_params() -> String {
"brands": [ "brands": [
{ "brand": "Chromium", "version": "128" }, { "brand": "Chromium", "version": "128" },
{ "brand": "Google Chrome", "version": "128" }, { "brand": "Google Chrome", "version": "128" },
{ "brand": "Modrinth App", "version": APP_VERSION },
{ "brand": "Not=A?Brand", "version": "99" }, { "brand": "Not=A?Brand", "version": "99" },
], ],
"fullVersion": "128.0.0.0", "fullVersion": "128.0.0.0",
"fullVersionList": [ "fullVersionList": [
{ "brand": "Chromium", "version": "128.0.0.0" }, { "brand": "Chromium", "version": "128.0.0.0" },
{ "brand": "Google Chrome", "version": "128.0.0.0" }, { "brand": "Google Chrome", "version": "128.0.0.0" },
{ "brand": "Modrinth App", "version": APP_VERSION },
{ "brand": "Not=A?Brand", "version": "99.0.0.0" }, { "brand": "Not=A?Brand", "version": "99.0.0.0" },
], ],
"platform": "Windows", "platform": "Windows",