| 260 | return False |
| 261 | |
| 262 | def patch_exe_beta(self): |
| 263 | with io.open(self.executable_path, "r+b") as fh: |
| 264 | content = fh.read() |
| 265 | match_injected_codeblock = re.search( |
| 266 | rb"\{window\.cdc.*?;\}", content |
| 267 | ) |
| 268 | target_bytes = None |
| 269 | if match_injected_codeblock: |
| 270 | target_bytes = match_injected_codeblock[0] |
| 271 | new_target_bytes = ( |
| 272 | b'{console.log("chromedriver is undetectable!")}'.ljust( |
| 273 | len(target_bytes), b" " |
| 274 | ) |
| 275 | ) |
| 276 | if target_bytes: |
| 277 | new_content = content.replace(target_bytes, new_target_bytes) |
| 278 | if new_content == content: |
| 279 | pass # Unable to patch driver |
| 280 | else: |
| 281 | fh.seek(0) |
| 282 | fh.write(new_content) |
| 283 | |
| 284 | def __repr__(self): |
| 285 | return "{0:s}({1:s})".format( |