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 · 9 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

@TassdarZeratul
Copy link

在l10n.json里照葫芦画瓢把对应得翻译添加上去不就得了,
image

@Tback1
Copy link
Author

Tback1 commented Jul 7, 2024

我都能定位到源代码位置了,我还不知道自己添加么。
问题是我是用的Chrome市场版本
第一,如果自己修改硬编码,每次更新,得不断重新手工注入
第二,Chrome的插件是做了hash验证的,手工直接修改json,Chrome直接报告插件损坏
image

@TassdarZeratul
Copy link

TassdarZeratul commented Jul 8, 2024

你都会自己添加了, 难道不会阻止更新? 难道不会加载自定义插件? 或是不知道自己该问什么?

@Tback1
Copy link
Author

Tback1 commented Jul 8, 2024

你都会自己添加了, 难道不会阻止更新? 难道不会加载自定义插件? 或是不知道自己该问什么?

很简单,我希望保留Chrome发行版。开发者模式自加载不就回到第一点,每出一个版本,我就得跟着手工更新维护。

@TassdarZeratul
Copy link

每个版本都跟随更新的意义何在?
image

@Tback1
Copy link
Author

Tback1 commented Jul 8, 2024

我发这个issue只是希望开发者如果考虑能够添加一个自定义函数的入口。无意接受手工修改方案。无需您手把手教学

@TassdarZeratul
Copy link

TassdarZeratul commented Jul 8, 2024

你的希望如此迂回辗转,开发者会看吗? 不如简单改一下ID: gfbliohnnapiefjpjlpjnehglfpaknnc 让chrome"认为"这个插件是你自己开发的,可以解决你搞不定的验证问题, 另外改个语言还可治疗强迫症
image

@Tback1
Copy link
Author

Tback1 commented Jul 8, 2024

问题是我无意于此,提个issue而已。你给出的方案我自己知道的,但是和我的目标不同。所以没必要这么做

@TassdarZeratul
Copy link

所以一揽子解决方案都是没必要的, 但"每次版本更新都跟着手工维护"则是必要的.

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