Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

只能用搜狗翻译切换其他翻译失效 #35

Open
Xudong-Mao opened this issue Aug 9, 2024 · 1 comment
Open

只能用搜狗翻译切换其他翻译失效 #35

Xudong-Mao opened this issue Aug 9, 2024 · 1 comment

Comments

@Xudong-Mao
Copy link

搜狗翻译正常,
image
其他翻译无法使用。
image
启动方式网页版

@TicklTock
Copy link
Contributor

可以自己修,utility文件夹下 网页翻译集合.ah2 文件
就一个js选择语法,我这里只修了deepl翻译

class Deepl_web_cd extends Web_cd
{
    __New()
    {
        url := 'https://www.deepl.com/zh/translator' 
        input_js :='
        (
            {          
                const editor = document.querySelector("d-textarea[name=\"source\"]");
                const inputbox = document.querySelector("d-textarea[name=\"source\"] > div");
                inputbox.textContent = "{1}";
                setTimeout(() => {
                    editor.dispatchEvent(new InputEvent("input"));
                }, 20);
            }
        )'
        out_put_js := '
        (
            {
                
                o = document.querySelector('d-textarea[name=\"target\"]')
                function callback3(records) {
                records.forEach(function(record) {
                    try
                    {
                        //aa = o.querySelector('[class="ordinary-output target-output clearfix"]');
                        console.log(o.textContent);
                        obj = window.chrome.webview.hostObjects.ahk;
                        obj.func(o.textContent);
                    }
                    catch
                    {
                        try
                        {
                            console.log('');
                            obj = window.chrome.webview.hostObjects.ahk;
                            obj.func('');
                        }
                        catch
                        {

                        }
                    }
                })
                }
                var ob3 = new MutationObserver(callback3)
                ob3.observe(o, {
                characterDataOldValue: true,
                attributes: true,
                childList: true,
                characterData: true,
                subtree: true
                })
            }
        )'
        super.__New(url, input_js, out_put_js,, 'deepl')
    }
    __Delete()
    {
        
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants