diff --git a/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py b/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py index 907c3b43..ba800cf2 100644 --- a/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py +++ b/LunaTranslator/LunaTranslator/translator/dev_chatgpt.py @@ -7,4 +7,4 @@ class TS(commonllmdev): function1 = 'url.includes("conversation")' function2 = r"""thistext = chunk.message.content.parts[0]""" textarea_selector = "#prompt-textarea" - button_selector = r"#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div > main > div.flex.h-full.flex-col.focus-visible\\:outline-0 > div.md\\:pt-0.dark\\:border-white\\/20.md\\:border-transparent.md\\:dark\\:border-transparent.w-full > div.text-base.px-3.md\\:px-4.m-auto.md\\:px-5.lg\\:px-1.xl\\:px-5 > div > form > div > div.flex.w-full.items-center > div > div > button" + button_selector = r"#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div > main > div.flex.h-full.flex-col.focus-visible\:outline-0 > div.md\:pt-0.dark\:border-white\/20.md\:border-transparent.md\:dark\:border-transparent.w-full > div.text-base.px-3.md\:px-4.m-auto.md\:px-5.lg\:px-1.xl\:px-5 > div > form > div > div.flex.w-full.items-center > div > div > button" diff --git a/LunaTranslator/LunaTranslator/translator/dev_llm_common.py b/LunaTranslator/LunaTranslator/translator/dev_llm_common.py index 9ec8631f..d84036a8 100644 --- a/LunaTranslator/LunaTranslator/translator/dev_llm_common.py +++ b/LunaTranslator/LunaTranslator/translator/dev_llm_common.py @@ -53,24 +53,24 @@ class commonllmdev(basetransdev): ) content = prompt + content self.Runtime_evaluate( - f"document.querySelector(`{self.textarea_selector}`).foucs()" + f"document.querySelector(`{repr(self.textarea_selector)}`).foucs()" ) self.send_keys(content) # chatgpt网站没有焦点时,用这个也可以。 self.Runtime_evaluate( - f'textarea=document.querySelector(`{self.textarea_selector}`);textarea.value="";event = new Event("input", {{bubbles: true, cancelable: true }});textarea.dispatchEvent(event);textarea.value=`{content}`;event = new Event("input", {{bubbles: true, cancelable: true }});textarea.dispatchEvent(event);' + f'textarea=document.querySelector({repr(self.textarea_selector)});textarea.value="";event = new Event("input", {{bubbles: true, cancelable: true }});textarea.dispatchEvent(event);textarea.value=`{content}`;event = new Event("input", {{bubbles: true, cancelable: true }});textarea.dispatchEvent(event);' ) try: # 月之暗面 while self.Runtime_evaluate( - f"document.querySelector(`{self.button_selector}`).disabled" + f"document.querySelector({repr(self.button_selector)}).disabled" )["result"]["value"]: time.sleep(0.1) except: pass self.Runtime_evaluate( - f"document.querySelector(`{self.button_selector}`).click()" + f"document.querySelector({repr(self.button_selector)}).click()" ) if self.config["usingstream"]: curr = "" diff --git a/LunaTranslator/LunaTranslator/translator/dev_theb.py b/LunaTranslator/LunaTranslator/translator/dev_theb.py new file mode 100644 index 00000000..ee1a3c67 --- /dev/null +++ b/LunaTranslator/LunaTranslator/translator/dev_theb.py @@ -0,0 +1,10 @@ +from translator.dev_llm_common import commonllmdev + + +class TS(commonllmdev): + target_url = "https://beta.theb.ai/home" + jsfile = "commonhookfetchstream.js" + function1 = 'url.includes("api/conversation")' + function2 = "thistext = chunk.args.content" + button_selector = r"#INPUT > div > div.max-w-\[66rem\].m-auto.z-2.border-2.border-n-3.rounded-xl.overflow-hidden.dark\:border-n-5.bg-white.dark\:bg-n-6 > div > button.group.absolute.right-3.bottom-2.rounded-xl.transition-colors.disabled\:bg-slate-400.disabled\:hover\:bg-slate-400.disabled\:cursor-no-drop.w-10.h-10.bg-primary-1.hover\:bg-primary-1\/90" + textarea_selector = "#textareaAutosize" diff --git a/LunaTranslator/files/defaultconfig/config.json b/LunaTranslator/files/defaultconfig/config.json index 6e59b537..0c492082 100644 --- a/LunaTranslator/files/defaultconfig/config.json +++ b/LunaTranslator/files/defaultconfig/config.json @@ -1585,6 +1585,13 @@ "name": "chatgpt", "is_gpt_like": true }, + "dev_theb": { + "use": false, + "color": "blue", + "type": "dev", + "name": "Theb.ai", + "is_gpt_like": true + }, "dev_moonshot": { "use": false, "color": "blue", diff --git a/LunaTranslator/files/defaultconfig/translatorsetting.json b/LunaTranslator/files/defaultconfig/translatorsetting.json index 7bffd259..34cd3610 100644 --- a/LunaTranslator/files/defaultconfig/translatorsetting.json +++ b/LunaTranslator/files/defaultconfig/translatorsetting.json @@ -830,6 +830,24 @@ } } }, + "dev_theb": { + "args": { + "usingstream": true, + "use_custom_prompt": false, + "custom_prompt": "" + }, + "argstype": { + "usingstream": { + "name": "流式输出", + "type": "switch" + }, + "custom_prompt": { + "name": "自定义_promt", + "type": "multiline", + "refswitch": "use_custom_prompt" + } + } + }, "dev_chatgpt_mirror": { "args": { "target_url": "https://chatgpt.com/",