fix: support non-ASCII characters (Cyrillic, CJK, emoji) in humanized typing

This commit is contained in:
lilos
2026-03-13 00:34:01 +01:00
parent 1bef989404
commit 1af25d67bc
5 changed files with 236 additions and 7 deletions
+9 -1
View File
@@ -41,7 +41,15 @@ def _get_nearby_key(ch: str) -> str:
def human_type(page: Any, raw: RawKeyboard, text: str, cfg: HumanConfig) -> None:
for i, ch in enumerate(text):
# Mistype chance — press wrong key, notice, backspace, then correct
# Non-ASCII characters (Cyrillic, CJK, emoji) — use insertText
if not ch.isascii():
sleep_ms(rand_range(cfg.key_hold))
raw.insert_text(ch)
if i < len(text) - 1:
_inter_char_delay(cfg)
continue
# Mistype chance — only for ASCII alphanumeric
if random.random() < cfg.mistype_chance and ch.isalnum():
wrong = _get_nearby_key(ch)
_type_normal_char(raw, wrong, cfg)
+9 -1
View File
@@ -22,7 +22,15 @@ class AsyncRawKeyboard(Protocol):
async def async_human_type(page: Any, raw: AsyncRawKeyboard, text: str, cfg: HumanConfig) -> None:
for i, ch in enumerate(text):
# Mistype chance — press wrong key, notice, backspace, then correct
# Non-ASCII characters (Cyrillic, CJK, emoji) — use insertText
if not ch.isascii():
await async_sleep_ms(rand_range(cfg.key_hold))
await raw.insert_text(ch)
if i < len(text) - 1:
await _inter_char_delay(cfg)
continue
# Mistype chance — only for ASCII alphanumeric
if random.random() < cfg.mistype_chance and ch.isalnum():
wrong = _get_nearby_key(ch)
await _type_normal_char(raw, wrong, cfg)