You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
chinese-programmer-wrong-pr.../tools/chromium_extension/js/app/box.js

43 lines
1.3 KiB

import * as utils from "./utils.js";
import * as components from "./components.js";
import * as searchEngine from "./search-engine.js";
let goToSearchPronounce = (word) => {
let search_engine_name = "gotToGoogleSearch";
// search_engine_name='gotToYouDaoSearch'
// search_engine_name = "goToBingDictSearch";
// search_engine_name = "goToBingSearch";
search_engine_name = "gotToYouDaoSearch";
// search_engine_name = "goToBaiduFanYiSearch";
//let tab = "current_tab";
let tab = "new_tab"; //修改默认为新标签页打开
let opener = components.getSearchEngineOpener();
if (opener && opener.expired_date) {
if (opener.expired_date > new Date().getTime()) {
if (opener.search_engine_name) {
search_engine_name = opener.search_engine_name;
}
if (opener.tab) {
tab = opener.tab;
}
}
}
if (search_engine_name && searchEngine[search_engine_name]) {
console.log(word);
let url = searchEngine[search_engine_name](word);
console.log(url);
if (tab === "new_tab") {
window.open(url, "_blank");
} else {
let iframe = components.getIframe();
iframe.setAttribute("src", url);
}
} else {
console.log("search engine no found !");
}
};
let box = { ...utils, ...components, ...searchEngine, goToSearchPronounce };
export default box;