From 347137f5976e36b1eda1824347acc56177bad4c9 Mon Sep 17 00:00:00 2001 From: jingjingxyk Date: Thu, 16 Jun 2022 08:41:04 +0800 Subject: [PATCH] fix error and add new search engine --- tools/chromium_extension/js/app/box.js | 3 ++- tools/chromium_extension/js/app/components.js | 2 ++ tools/chromium_extension/js/app/search-engine.js | 7 ++++++- tools/chromium_extension/js/app/until.js | 2 +- tools/chromium_extension/manifest.json | 3 ++- .../rules/remove_content_security_policy.json | 7 ++++++- 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/tools/chromium_extension/js/app/box.js b/tools/chromium_extension/js/app/box.js index 86ef3f3..97b8205 100644 --- a/tools/chromium_extension/js/app/box.js +++ b/tools/chromium_extension/js/app/box.js @@ -6,8 +6,9 @@ let goToSearchPronounce = (word) => { let search_engine_name = "gotToGoogleSearch"; // search_engine_name='gotToYouDaoSearch' // search_engine_name = "goToBingDictSearch"; - //search_engine_name = "goToBingSearch"; + // search_engine_name = "goToBingSearch"; search_engine_name = "gotToYouDaoSearch"; + // search_engine_name = "goToBaiduFanYiSearch"; let tab = "current_tab"; let opener = components.getSearchEngineOpener(); diff --git a/tools/chromium_extension/js/app/components.js b/tools/chromium_extension/js/app/components.js index 0b97cf5..c4a159a 100644 --- a/tools/chromium_extension/js/app/components.js +++ b/tools/chromium_extension/js/app/components.js @@ -43,6 +43,8 @@ let getIframe = () => { "id", "chinese-programmer-wrong-pronunciation-custom-iframe" ); + iframe.setAttribute("security", "restricted"); + //iframe.setAttribute('sandbox',"") aside.appendChild(iframe); custom_box.appendChild(aside); document.body.appendChild(custom_box); diff --git a/tools/chromium_extension/js/app/search-engine.js b/tools/chromium_extension/js/app/search-engine.js index 53ba1f5..c9ba0d0 100644 --- a/tools/chromium_extension/js/app/search-engine.js +++ b/tools/chromium_extension/js/app/search-engine.js @@ -15,7 +15,11 @@ let goToBingSearch = (word) => { return `https://cn.bing.com/search?q=how%20to%20pronounce%20${word}`; }; let goToBaiduDictSearch = (word) => { - return ` https://dict.baidu.com/s?wd=${word}`; + return `https://dict.baidu.com/s?wd=${word}`; +}; + +let goToBaiduFanYiSearch = (word) => { + return `https://fanyi.baidu.com/#en/zh/${word}`; }; let goToBaiDuHanYu = () => { @@ -36,4 +40,5 @@ export { goToBingDictSearch, goToBingSearch, goToBaiduDictSearch, + goToBaiduFanYiSearch, }; diff --git a/tools/chromium_extension/js/app/until.js b/tools/chromium_extension/js/app/until.js index 6ab4e31..6d3078c 100644 --- a/tools/chromium_extension/js/app/until.js +++ b/tools/chromium_extension/js/app/until.js @@ -100,5 +100,5 @@ export { getParameterValue, sleep, getMediaDevices, - createJsonFile, + createJSONFile, }; diff --git a/tools/chromium_extension/manifest.json b/tools/chromium_extension/manifest.json index e598086..4a79567 100644 --- a/tools/chromium_extension/manifest.json +++ b/tools/chromium_extension/manifest.json @@ -24,7 +24,8 @@ "*://www.bing.com/*", "*://dict.baidu.com/*", "*://www.youdao.com/*", - "*://dict.youdao.com/*" + "*://dict.youdao.com/*", + "*://fanyi.baidu.com/*" ], "web_accessible_resources": [ { diff --git a/tools/chromium_extension/rules/remove_content_security_policy.json b/tools/chromium_extension/rules/remove_content_security_policy.json index 19875e7..5cf80b3 100644 --- a/tools/chromium_extension/rules/remove_content_security_policy.json +++ b/tools/chromium_extension/rules/remove_content_security_policy.json @@ -43,7 +43,12 @@ "githubusercontent.com", "www.google.com", "cn.bing.com", - "www.bing.com" + "www.bing.com", + "fanyi.baidu.com", + "dict.baidu.com", + "www.youdao.com", + "dict.youdao.com", + "fanyi.baidu.com" ], "resourceTypes": [ "main_frame",