stealth: fix platform/UA mismatch and hide internal globals from Object.keys
navigator.platform returned "Win32" while navigator.userAgent said Linux when
using the stealth client. page.rs now calls set_platform("Linux x86_64", "Linux", "")
alongside set_user_agent when the stealth client is active.
bootstrap.js: pre-declare 71 internal _* globals as enumerable:false before
var runs, so they don't show up in Object.keys(window) on real pages.
This commit is contained in:
1 parent
534de77882
commit
ac75cf52a6
2 files changed
+62
-9
No files matched your search
@@ -276,18 +276,30 @@ impl Page {
|
||||
#[cfg(feature = "stealth")]
|
||||
if self.stealth_client.is_some() {
|
||||
rt.set_user_agent(obscura_net::STEALTH_USER_AGENT);
|
||||
} else if let Ok(ua) = self.http_client.user_agent.try_read() {
|
||||
rt.set_user_agent(&ua);
|
||||
// Match platform to the Linux UA so navigator.platform and
|
||||
// userAgentData.platform are consistent with navigator.userAgent.
|
||||
rt.set_platform("Linux x86_64", "Linux", "");
|
||||
} else {
|
||||
if let Ok(ua) = self.http_client.user_agent.try_read() {
|
||||
rt.set_user_agent(&ua);
|
||||
}
|
||||
rt.set_platform(
|
||||
&self.context.platform,
|
||||
&self.context.ua_platform,
|
||||
&self.context.ua_platform_version,
|
||||
);
|
||||
}
|
||||
#[cfg(not(feature = "stealth"))]
|
||||
if let Ok(ua) = self.http_client.user_agent.try_read() {
|
||||
rt.set_user_agent(&ua);
|
||||
{
|
||||
if let Ok(ua) = self.http_client.user_agent.try_read() {
|
||||
rt.set_user_agent(&ua);
|
||||
}
|
||||
rt.set_platform(
|
||||
&self.context.platform,
|
||||
&self.context.ua_platform,
|
||||
&self.context.ua_platform_version,
|
||||
);
|
||||
}
|
||||
rt.set_platform(
|
||||
&self.context.platform,
|
||||
&self.context.ua_platform,
|
||||
&self.context.ua_platform_version,
|
||||
);
|
||||
if let Some((lat, lon)) = env_geolocation() {
|
||||
rt.set_geolocation(lat, lon);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user