feat(StealthyFetcher): add the ability to add init_script to context

This commit is contained in:
Karim shoair
2025-09-02 16:19:22 +03:00
parent d49e047736
commit 9543f171aa
3 changed files with 30 additions and 0 deletions
@@ -90,6 +90,7 @@ class CamoufoxConfig(Struct, kw_only=True, frozen=False):
solve_cloudflare: bool = False
wait: int | float = 0
timeout: int | float = 30000
init_script: Optional[str] = None
page_action: Optional[Callable] = None
wait_selector: Optional[str] = None
addons: Optional[List[str]] = None
@@ -131,6 +132,15 @@ class CamoufoxConfig(Struct, kw_only=True, frozen=False):
f"Addon's path is not a folder, you need to pass a folder of the extracted addon: {addon}"
)
if self.init_script is not None:
script_path = Path(self.init_script)
if not script_path.exists():
raise ValueError("Init script path not found")
elif not script_path.is_file():
raise ValueError("Init script is not a file")
elif not script_path.is_absolute():
raise ValueError("Init script is not a absolute path")
if not self.cookies:
self.cookies = []
if self.solve_cloudflare and self.timeout < 60_000: