File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919from ..requests import get_nodriver_session
2020from ..image import is_accepted_format
2121from .helper import get_last_user_message
22- from .Copilot import click_trunstile
2322from .. import debug
2423
2524class Conversation (JsonConversation ):
@@ -205,4 +204,20 @@ async def create_authed(
205204 if not done :
206205 raise MissingAuthError (f"Invalid response: { last_msg } " )
207206 if sources :
208- yield Sources (sources .values ())
207+ yield Sources (sources .values ())
208+
209+ if has_nodriver :
210+ async def click_trunstile (page : nodriver .Tab , element = 'document.getElementById("cf-turnstile")' ):
211+ for _ in range (3 ):
212+ size = None
213+ for idx in range (15 ):
214+ size = await page .js_dumps (f'{ element } ?.getBoundingClientRect()||{{}}' )
215+ debug .log (f"Found size: { size .get ('x' ), size .get ('y' )} " )
216+ if "x" not in size :
217+ break
218+ await page .flash_point (size .get ("x" ) + idx * 3 , size .get ("y" ) + idx * 3 )
219+ await page .mouse_click (size .get ("x" ) + idx * 3 , size .get ("y" ) + idx * 3 )
220+ await asyncio .sleep (2 )
221+ if "x" not in size :
222+ break
223+ debug .log ("Finished clicking trunstile." )
You can’t perform that action at this time.
0 commit comments