chore: move header setting thing to RewardsTaskUtils

This commit is contained in:
Mally Dang
2026-09-07 18:06:43 +07:00
parent afccf81f8f
commit 3c6b29e857
2 changed files with 10 additions and 8 deletions
-8
View File
@@ -42,14 +42,6 @@ def run_account(account: accounts.Account) -> bool:
"""Work one account. Returns whether the browser started."""
try:
driver = webdriver.Edge(options=build_options(account))
# Set headers to spoof the rewards app for the rewards only quests
driver.execute_cdp_cmd("Network.enable", {})
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 Edg/151.0.0.0 MSRewards/Desktop/1.1.0",
"X-Rewards-Source": "msrewards-desktop",
}
driver.execute_cdp_cmd("Network.setExtraHTTPHeaders", {"headers": headers})
except SessionNotCreatedException as exc:
# Chromium allows one process per user data directory. When the profile
# is already open the driver's copy exits during startup, and selenium
+10
View File
@@ -24,6 +24,16 @@ class RewardsTaskUtils:
def __init__(self, driver: webdriver.Edge):
self.driver = driver
# Set headers to spoof the rewards app for the rewards only quests
self.driver.execute_cdp_cmd("Network.enable", {})
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36 Edg/151.0.0.0 MSRewards/Desktop/1.1.0",
"X-Rewards-Source": "msrewards-desktop",
}
self.driver.execute_cdp_cmd("Network.setExtraHTTPHeaders", {"headers": headers})
self.driver.get("https://rewards.bing.com/")
self.tab_utils = tab_utils.TabUtils(driver)