Evilmass commited on
Commit
58c0fbc
·
1 Parent(s): 895c055

tsdm: add has_cliwork timeout

Browse files
Files changed (1) hide show
  1. _playwright/tsdm.py +3 -6
_playwright/tsdm.py CHANGED
@@ -81,23 +81,20 @@ async def cliwork(page):
81
  return "tsdm_not_login"
82
 
83
  await page.goto(tsdm_url) # 切换回电脑版
84
- await page.wait_for_load_state()
85
  await page.goto(tsdm_cliwork_url)
86
 
87
  # 已经打工会跳转回首页
88
- if (
89
- await page.get_by_text("需要等待").is_visible()
90
- or await page.get_by_text("欢迎新会员").is_visible()
91
- ):
92
  has_work = "今天已打工"
93
  tsdm_logger.info(has_work)
94
  msg.append(has_work)
95
  else:
96
  await page.locator("#workstart").is_enabled()
97
- for pid in tsdm_plugin_id[1:4]:
98
  await page.locator(f"#np_advid{pid}").get_by_role("link").click()
99
  page.on("popup", close_popup) # handle popup 不能 await
100
 
 
101
  await page.bring_to_front() # 回到第一个标签页
102
  await page.locator("#workstart").click() # 领取奖励
103
  work_res = "打工成功"
 
81
  return "tsdm_not_login"
82
 
83
  await page.goto(tsdm_url) # 切换回电脑版
 
84
  await page.goto(tsdm_cliwork_url)
85
 
86
  # 已经打工会跳转回首页
87
+ if await page.get_by_text("需要等待").is_visible(timeout=3) or await page.get_by_text("欢迎新会员").is_visible(timeout=3):
 
 
 
88
  has_work = "今天已打工"
89
  tsdm_logger.info(has_work)
90
  msg.append(has_work)
91
  else:
92
  await page.locator("#workstart").is_enabled()
93
+ for pid in tsdm_plugin_id:
94
  await page.locator(f"#np_advid{pid}").get_by_role("link").click()
95
  page.on("popup", close_popup) # handle popup 不能 await
96
 
97
+ await page.pause()
98
  await page.bring_to_front() # 回到第一个标签页
99
  await page.locator("#workstart").click() # 领取奖励
100
  work_res = "打工成功"