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

请问如何将替换“Search selected with xxxx”“转变为 用xxxx搜索选中文本 #2114

Open
Tback1 opened this issue May 10, 2024 · 0 comments

Comments

@Tback1
Copy link

Tback1 commented May 10, 2024

突然想修改这个,统一搜索效果。但是突然发现居然没有这个参数支持

image|200

而且挺有意思的是,我将百度和bing的搜索触发快捷键做了替换

api.removeSearchAlias('d');
api.removeSearchAlias('b');
api.removeSearchAlias('s');
api.removeSearchAlias('y');
api.removeSearchAlias('w');

api.addSearchAlias('w', 'baidu', 'https://www.baidu.com/s?wd=', 's', 'https://suggestion.baidu.com/su?cb=&wd=', function (response) {
    var res = response.text.match(/,s:\[("[^\]]+")]}/);
    return res ? res[1].replace(/"/g, '').split(",") : [];
});

api.addSearchAlias('b', 'bing', 'https://www.bing.com/search?setmkt=en-us&setlang=en-us&q=', 's', 'https://api.bing.com/osjson.aspx?query=', function (response) {
    var res = JSON.parse(response.text);
    return res[1];
});

api.addSearchAlias('dq', '豆瓣电影', 'https://search.douban.com/movie/subject_search?search_text={0}&cat=1002', 's', 'https://search.douban.com/movie/subject_search?search_text={0}&cat=1002', function(response) {
    var res = JSON.parse(response.text);
    return res.map(function(r){
        return r.phrase;
    });
});

api.addSearchAlias('da', '豆瓣图书', 'https://search.douban.com/book/subject_search?search_text={0}&cat=1001', 's', 'https://search.douban.com/book/subject_search?search_text={0}&cat=1001', function(response) {
    var res = JSON.parse(response.text);
    return res.map(function(r){
        return r.phrase;
    });
});

本以为,这样百度和bing也会变成 Search xxx 这样的效果, 结果这两者还是得到了中文支持。看了一下代码,原来是编码里做了硬翻译。那这个问题能有解么?

image|200

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

1 participant