diff --git a/src/apis/index.js b/src/apis/index.js
index 42c9d32..9f70a3b 100644
--- a/src/apis/index.js
+++ b/src/apis/index.js
@@ -148,20 +148,20 @@ export const apiMicrosoftDict = async (text) => {
});
const aus = [];
- const $audioUS = doc.querySelector("#bigaud_us");
const $audioUK = doc.querySelector("#bigaud_uk");
- if ($audioUS) {
- const audioUS = host + $audioUS?.dataset?.mp3link;
- const $phoneticUS = $audioUS.parentElement?.previousElementSibling;
- const phoneticUS = $phoneticUS?.textContent?.trim();
- aus.push({ key: "US", audio: audioUS, phonetic: phoneticUS });
- }
+ const $audioUS = doc.querySelector("#bigaud_us");
if ($audioUK) {
const audioUK = host + $audioUK?.dataset?.mp3link;
const $phoneticUK = $audioUK.parentElement?.previousElementSibling;
const phoneticUK = $phoneticUK?.textContent?.trim();
aus.push({ key: "UK", audio: audioUK, phonetic: phoneticUK });
}
+ if ($audioUS) {
+ const audioUS = host + $audioUS?.dataset?.mp3link;
+ const $phoneticUS = $audioUS.parentElement?.previousElementSibling;
+ const phoneticUS = $phoneticUS?.textContent?.trim();
+ aus.push({ key: "US", audio: audioUS, phonetic: phoneticUS });
+ }
const res = { word, trs, aus };
putHttpCachePolyfill(cacheInput, null, res);
@@ -266,7 +266,7 @@ export const apiYoudaoDict = async (text) => {
};
const input = `https://dict.youdao.com/jsonapi_s?${queryString.stringify(params)}`;
const body = queryString.stringify({
- q: "search",
+ q: text,
le: "en",
t: 3,
client: "web",
diff --git a/src/background.js b/src/background.js
index 429be40..af87b43 100644
--- a/src/background.js
+++ b/src/background.js
@@ -158,7 +158,7 @@ async function updateCspRules({ csplist, orilist }) {
id: ORI_RULE_START_ID + index,
action: {
type: "modifyHeaders",
- requestHeaders: [{ header: "Origin", operation: "remove" }],
+ requestHeaders: [{ header: "Origin", operation: "set", value: url }],
},
condition: {
urlFilter: url,
diff --git a/src/config/i18n.js b/src/config/i18n.js
index 13947f3..ad001f2 100644
--- a/src/config/i18n.js
+++ b/src/config/i18n.js
@@ -530,9 +530,9 @@ export const I18N = {
zh_TW: `1.其中 BuiltinAI 為瀏覽器內建AI翻譯,目前僅 Chrome 138 以上版本支援。`,
},
about_api_2: {
- zh: `2、暂未列出的接口,理论上都可以通过自定义接口的形式支持。`,
+ zh: `2、暂未列出的接口,理论上都可以通过自定义接口 (Custom) 的形式支持。`,
en: `2. Interfaces that have not yet been launched can theoretically be supported through custom interfaces.`,
- zh_TW: `2、暫未列出的介面,理論上都可透過自訂介面的形式支援。`,
+ zh_TW: `2、暫未列出的介面,理論上都可透過自訂介面 (Custom) 的形式支援。`,
},
about_api_proxy: {
zh: `查看自建一个翻译接口代理`,
diff --git a/src/views/Options/FavWords.js b/src/views/Options/FavWords.js
index 475be85..2bc09e4 100644
--- a/src/views/Options/FavWords.js
+++ b/src/views/Options/FavWords.js
@@ -87,11 +87,12 @@ export default function FavWords() {
for (const word of wordList) {
try {
const data = await dict.apiFn(word);
+ const title = `## ${dict.reWord(data) || word}`;
const tran = dict
.toText(data)
.map((line) => `- ${line}`)
.join("\n");
- tranList.push([`## ${word}`, tran].join("\n"));
+ tranList.push([title, tran].join("\n"));
} catch (err) {
kissLog("export translation", err);
}
diff --git a/src/views/Selection/DictCont.js b/src/views/Selection/DictCont.js
index 416c2a5..6251a57 100644
--- a/src/views/Selection/DictCont.js
+++ b/src/views/Selection/DictCont.js
@@ -9,7 +9,7 @@ import CopyBtn from "./CopyBtn";
import { useAsyncNow } from "../../hooks/Fetch";
import { dictHandlers } from "./DictHandler";
-function DictBody({ text, setCopyText, dict }) {
+function DictBody({ text, setCopyText, setRealWord, dict }) {
const { loading, error, data } = useAsyncNow(dict.apiFn, text);
useEffect(() => {
@@ -17,9 +17,11 @@ function DictBody({ text, setCopyText, dict }) {
return;
}
- const copyText = [text, dict.toText(data).join("\n")].join("\n");
+ const realWord = dict.reWord(data) || text;
+ const copyText = [realWord, dict.toText(data).join("\n")].join("\n");
+ setRealWord(realWord);
setCopyText(copyText);
- }, [data, text, dict, setCopyText]);
+ }, [data, text, dict, setCopyText, setRealWord]);
const uiAudio = useMemo(() => dict.uiAudio(data), [data, dict]);
const uiTrans = useMemo(() => dict.uiTrans(data), [data, dict]);
@@ -46,6 +48,7 @@ function DictBody({ text, setCopyText, dict }) {
export default function DictCont({ text, enDict }) {
const [copyText, setCopyText] = useState(text);
+ const [realWord, setRealWord] = useState(text);
const dict = dictHandlers[enDict];
return (
@@ -53,18 +56,25 @@ export default function DictCont({ text, enDict }) {
{text && (
- {text}
+ {realWord}
-
+
)}
- {dict && }
+ {dict && (
+
+ )}
);
}
diff --git a/src/views/Selection/DictHandler.js b/src/views/Selection/DictHandler.js
index 4a81aca..6720ea3 100644
--- a/src/views/Selection/DictHandler.js
+++ b/src/views/Selection/DictHandler.js
@@ -6,15 +6,16 @@ import { apiMicrosoftDict, apiYoudaoDict } from "../../apis";
export const dictHandlers = {
[OPT_DICT_BING]: {
apiFn: apiMicrosoftDict,
+ reWord: (data) => data?.word,
toText: (data) =>
- data.trs?.map(({ pos, def }) => `${pos ? `[${pos}] ` : ""}${def}`) || [],
+ data?.trs?.map(({ pos, def }) => `${pos ? `[${pos}] ` : ""}${def}`) || [],
uiAudio: (data) => (
- {data?.aus.map(({ key, audio, phonetic }) => (
+ {data?.aus?.map(({ key, audio, phonetic }) => (
{phonetic}
@@ -35,11 +36,27 @@ export const dictHandlers = {
},
[OPT_DICT_YOUDAO]: {
apiFn: apiYoudaoDict,
+ reWord: (data) => data?.ec?.word?.["return-phrase"],
toText: (data) =>
data?.ec?.word?.trs?.map(
({ pos, tran }) => `${pos ? `[${pos}] ` : ""}${tran}`
) || [],
- uiAudio: () => null,
+ uiAudio: (data) => (
+
+
+ {`UK [${data?.ec?.word?.ukphone}]`}
+
+
+ {`US [${data?.ec?.word?.usphone}]`}
+
+
+ ),
uiTrans: (data) => (
{data?.ec?.word?.trs?.map(({ pos, tran }, idx) => (