This commit is contained in:
恍兮惚兮 2024-07-21 16:11:47 +08:00
parent 28face8da2
commit 26500e6ffc
4 changed files with 8 additions and 58 deletions

View File

@ -4,15 +4,13 @@ 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("#translation > span").innerText=""'
)
self.Runtime_evaluate('document.querySelector("#fakeArea").innerText=""')
self.Runtime_evaluate('document.querySelector("#fakeArea").click()')
self.send_keys(content)
last = self.wait_for_result(
'document.querySelector("#translation > span").innerText', self.last
return self.wait_for_result(
'document.querySelector("#translation > span").innerText'
)
self.last = last
return self.last

View File

@ -8,6 +8,9 @@ class TS(basetransdev):
target_url = "https://translate.google.com/"
def translate(self, content):
self.Runtime_evaluate(
'document.querySelector("#yDmH0d > c-wiz > div > div.ToWKne > c-wiz > div.OlSOob > c-wiz > div.ccvoYb > div.AxqVh > div.OPPzxe > c-wiz.sciAJc > div > div.usGWQd > div > div.lRu31").innerText=""'
)
if "lastlang" not in dir(self) or self.lastlang != (self.srclang, self.tgtlang):
self.Page_navigate(
"https://translate.google.com/?sl={}&tl={}".format(

View File

@ -1,45 +0,0 @@
from translator.basetranslator_dev import basetransdev
class TS(basetransdev):
target_url = "https://fanyi.qq.com/"
def translate(self, content):
tgtlist = [
"zh",
"en",
"ja",
"ko",
"fr",
"es",
"it",
"de",
"tr",
"ru",
"pt",
"vi",
"id",
"th",
"ms",
"ar",
"hi",
]
if self.tgtlang in tgtlist:
tgtidx = tgtlist.index(self.srclang) + 1
else:
tgtidx = 1
self.Runtime_evaluate(
'document.querySelector("div.textpanel-tool.tool-close").click()'
)
self.Runtime_evaluate(
"""document.querySelector("#language-button-group-source > div.language-button-dropdown.language-source > ul > li:nth-child(1) > span").click();
document.querySelector("#language-button-group-target > div.language-button-dropdown.language-target > ul > li:nth-child({}) > span");
document.getElementsByClassName('textinput')[0].value=`{}`;
document.getElementsByClassName('language-translate-button')[0].click();
""".format(
tgtidx, content
)
)
return self.wait_for_result(
"document.getElementsByClassName('textpanel-target-textblock')[0].innerText"
)

View File

@ -1585,12 +1585,6 @@
"type": "dev",
"name": "必应"
},
"tx_dev": {
"use": false,
"color": "blue",
"type": "dev",
"name": "tx"
},
"baidu_dev": {
"use": false,
"color": "blue",