Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove support for random_attributes, ua_strings, screen_res #745 #775

Merged
merged 11 commits into from
Nov 4, 2020
4 changes: 1 addition & 3 deletions automation/BrowserManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def __init__(self, manager_params, browser_params) -> None:
self.restart_required = False

self.current_timeout: Optional[int] = None # timeout of the current command
# dict of additional browser profile settings (e.g. screen_res)
self.browser_settings = None
ankushduacodes marked this conversation as resolved.
Show resolved Hide resolved
self.browser_manager = None # process that controls browser

Expand Down Expand Up @@ -110,8 +109,7 @@ def launch_browser_manager(self):
)
# make sure browser loads crashed profile
self.browser_params['recovery_tar'] = tempdir
# don't re-randomize attributes
self.browser_params['random_attributes'] = False

crash_recovery = True
else:
"""
Expand Down
38 changes: 2 additions & 36 deletions automation/DeployBrowsers/deploy_firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,40 +82,6 @@ def deploy_firefox(status_queue, browser_params, manager_params, crash_recovery)
)
status_queue.put(("STATUS", "Profile Tar", None))

if browser_params["random_attributes"] and profile_settings is None:
logger.debug(
"BROWSER %i: Loading random attributes for browser"
% browser_params["browser_id"]
)
profile_settings = dict()

# choose a random screen-res from list
resolutions = list()
with open(os.path.join(root_dir, "screen_resolutions.txt"), "r") as f:
for line in f:
resolutions.append(tuple(line.strip().split(",")))
profile_settings["screen_res"] = random.choice(resolutions)

# set a random user agent from list
ua_strings = list()
with open(os.path.join(root_dir, "user_agent_strings.txt"), "r") as f:
for line in f:
ua_strings.append(line.strip())
profile_settings["ua_string"] = random.choice(ua_strings)

# If profile settings still not set - set defaults
if profile_settings is None:
profile_settings = dict()
profile_settings["screen_res"] = DEFAULT_SCREEN_RES
profile_settings["ua_string"] = None

if profile_settings["ua_string"] is not None:
logger.debug(
"BROWSER %i: Overriding user agent string to '%s'"
% (browser_params["browser_id"], profile_settings["ua_string"])
)
fo.set_preference("general.useragent.override", profile_settings["ua_string"])

display_mode = browser_params["display_mode"]
display_pid = None
display_port = None
Expand All @@ -125,7 +91,7 @@ def deploy_firefox(status_queue, browser_params, manager_params, crash_recovery)
fo.add_argument("--height={}".format(DEFAULT_SCREEN_RES[1]))
if display_mode == "xvfb":
try:
display = Display(visible=0, size=profile_settings["screen_res"])
display = Display(visible=0, size=DEFAULT_SCREEN_RES)
display.start()
display_pid, display_port = display.pid, display.cmd_param[-1][1:]
except EasyProcessError:
Expand Down Expand Up @@ -227,7 +193,7 @@ def deploy_firefox(status_queue, browser_params, manager_params, crash_recovery)
)

# set window size
driver.set_window_size(*profile_settings["screen_res"])
driver.set_window_size(*DEFAULT_SCREEN_RES)

# Get browser process pid
if hasattr(driver, "service") and hasattr(driver.service, "process"):
Expand Down
3 changes: 0 additions & 3 deletions automation/default_browser_params.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
"browser": "firefox",
"prefs": {},
"tp_cookies": "always",

"bot_mitigation": false,
"profile_archive_dir": null,
"recovery_tar": null,

"random_attributes": false,
"donottrack": false,
"tracking-protection": false
}