mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2024-12-28 08:04:13 +08:00
fix
This commit is contained in:
parent
c95fa10b88
commit
e3505563e3
@ -100,7 +100,7 @@ class basetransdev(basetrans):
|
||||
time.sleep(0.1)
|
||||
|
||||
def send_keys(self, text):
|
||||
self._SendRequest("Input.setIgnoreInputEvents", {"ignore": False})
|
||||
#self._SendRequest("Input.setIgnoreInputEvents", {"ignore": False})
|
||||
try:
|
||||
self._SendRequest("Input.insertText", {"text": text})
|
||||
except:
|
||||
@ -127,4 +127,4 @@ class basetransdev(basetrans):
|
||||
)
|
||||
# self._SendRequest('Input.dispatchKeyEvent', {'type': 'keyUp', 'modifiers': 0, 'timestamp': 0, 'text': '', 'unmodifiedText': '', 'keyIdentifier': '', 'code': f'Key{char.upper()}', 'key': char, 'windowsVirtualKeyCode': code, 'nativeVirtualKeyCode': code, 'autoRepeat': False, 'isKeypad': False, 'isSystemKey': False, 'location': 0})
|
||||
|
||||
self._SendRequest("Input.setIgnoreInputEvents", {"ignore": True})
|
||||
#self._SendRequest("Input.setIgnoreInputEvents", {"ignore": True})
|
||||
|
@ -4,10 +4,15 @@ from translator.basetranslator_dev import basetransdev
|
||||
class TS(basetransdev):
|
||||
target_url = "https://translate.yandex.com/"
|
||||
|
||||
def inittranslator(self):
|
||||
self.last = ""
|
||||
|
||||
def translate(self, content):
|
||||
self.Runtime_evaluate('document.querySelector("#fakeArea").innerText=""')
|
||||
self.Runtime_evaluate('document.querySelector("#fakeArea").click()')
|
||||
self.send_keys(content)
|
||||
return self.wait_for_result(
|
||||
'document.querySelector("#translation > span").innerText'
|
||||
last = self.wait_for_result(
|
||||
'document.querySelector("#translation > span").innerText', self.last
|
||||
)
|
||||
self.last = last
|
||||
return self.last
|
||||
|
Loading…
x
Reference in New Issue
Block a user