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

41 lines
1.2 KiB

import * as until from "./until.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";
let tab = "current_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 = { ...until, ...components, ...searchEngine, goToSearchPronounce };
export default box;