fix: bing dict
This commit is contained in:
@@ -97,7 +97,7 @@ const userscriptWebpack = (config, env) => {
|
|||||||
// @connect generativelanguage.googleapis.com
|
// @connect generativelanguage.googleapis.com
|
||||||
// @connect api-edge.cognitive.microsofttranslator.com
|
// @connect api-edge.cognitive.microsofttranslator.com
|
||||||
// @connect edge.microsoft.com
|
// @connect edge.microsoft.com
|
||||||
// @connect cn.bing.com
|
// @connect bing.com
|
||||||
// @connect api-free.deepl.com
|
// @connect api-free.deepl.com
|
||||||
// @connect api.deepl.com
|
// @connect api.deepl.com
|
||||||
// @connect www2.deepl.com
|
// @connect www2.deepl.com
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ import { isBuiltinAIAvailable } from "../libs/browser";
|
|||||||
import { chromeDetect, chromeTranslate } from "../libs/builtinAI";
|
import { chromeDetect, chromeTranslate } from "../libs/builtinAI";
|
||||||
import { fnPolyfill } from "../libs/fetch";
|
import { fnPolyfill } from "../libs/fetch";
|
||||||
import { getFetchPool } from "../libs/pool";
|
import { getFetchPool } from "../libs/pool";
|
||||||
import { isFirefox } from "../libs/client";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 同步数据
|
* 同步数据
|
||||||
@@ -134,17 +133,13 @@ export const apiMicrosoftDict = async (text) => {
|
|||||||
return cache;
|
return cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
const host = "https://cn.bing.com";
|
const host = "https://www.bing.com";
|
||||||
const url = `${host}/dict/search?q=${text}`;
|
const url = `${host}/dict/search?q=${text}&FORM=BDVSP6&cc=cn`;
|
||||||
let str = "";
|
const str = await fetchData(
|
||||||
if (isFirefox) {
|
url,
|
||||||
const response = await fetch(url);
|
{ credentials: "include" },
|
||||||
if (response.ok) {
|
{ useCache: false }
|
||||||
str = await response.text();
|
);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
str = await fetchData(url, {}, { useCache: false });
|
|
||||||
}
|
|
||||||
if (!str) {
|
if (!str) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import {
|
|||||||
CMD_OPEN_OPTIONS,
|
CMD_OPEN_OPTIONS,
|
||||||
CMD_OPEN_TRANBOX,
|
CMD_OPEN_TRANBOX,
|
||||||
CLIENT_THUNDERBIRD,
|
CLIENT_THUNDERBIRD,
|
||||||
|
MSG_SET_LOGLEVEL,
|
||||||
} from "./config";
|
} from "./config";
|
||||||
import { getSettingWithDefault, tryInitDefaultData } from "./libs/storage";
|
import { getSettingWithDefault, tryInitDefaultData } from "./libs/storage";
|
||||||
import { trySyncSettingAndRules } from "./libs/sync";
|
import { trySyncSettingAndRules } from "./libs/sync";
|
||||||
@@ -273,6 +274,7 @@ const messageHandlers = {
|
|||||||
[MSG_COMMAND_SHORTCUTS]: () => browser.commands.getAll(),
|
[MSG_COMMAND_SHORTCUTS]: () => browser.commands.getAll(),
|
||||||
[MSG_BUILTINAI_DETECT]: (args) => chromeDetect(args),
|
[MSG_BUILTINAI_DETECT]: (args) => chromeDetect(args),
|
||||||
[MSG_BUILTINAI_TRANSLATE]: (args) => chromeTranslate(args),
|
[MSG_BUILTINAI_TRANSLATE]: (args) => chromeTranslate(args),
|
||||||
|
[MSG_SET_LOGLEVEL]: (args) => logger.setLevel(args),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export const MSG_INJECT_CSS = "inject_css";
|
|||||||
export const MSG_UPDATE_CSP = "update_csp";
|
export const MSG_UPDATE_CSP = "update_csp";
|
||||||
export const MSG_BUILTINAI_DETECT = "builtinai_detect";
|
export const MSG_BUILTINAI_DETECT = "builtinai_detect";
|
||||||
export const MSG_BUILTINAI_TRANSLATE = "builtinai_translte";
|
export const MSG_BUILTINAI_TRANSLATE = "builtinai_translte";
|
||||||
|
export const MSG_SET_LOGLEVEL = "set_loglevel";
|
||||||
|
|
||||||
export const MSG_XHR_DATA_YOUTUBE = "KISS_XHR_DATA_YOUTUBE";
|
export const MSG_XHR_DATA_YOUTUBE = "KISS_XHR_DATA_YOUTUBE";
|
||||||
// export const MSG_GLOBAL_VAR_FETCH = "KISS_GLOBAL_VAR_FETCH";
|
// export const MSG_GLOBAL_VAR_FETCH = "KISS_GLOBAL_VAR_FETCH";
|
||||||
|
|||||||
@@ -6,11 +6,17 @@ import {
|
|||||||
useEffect,
|
useEffect,
|
||||||
} from "react";
|
} from "react";
|
||||||
import Alert from "@mui/material/Alert";
|
import Alert from "@mui/material/Alert";
|
||||||
import { STOKEY_SETTING, DEFAULT_SETTING, KV_SETTING_KEY } from "../config";
|
import {
|
||||||
|
STOKEY_SETTING,
|
||||||
|
DEFAULT_SETTING,
|
||||||
|
KV_SETTING_KEY,
|
||||||
|
MSG_SET_LOGLEVEL,
|
||||||
|
} from "../config";
|
||||||
import { useStorage } from "./Storage";
|
import { useStorage } from "./Storage";
|
||||||
import { debounceSyncMeta } from "../libs/storage";
|
import { debounceSyncMeta } from "../libs/storage";
|
||||||
import Loading from "./Loading";
|
import Loading from "./Loading";
|
||||||
import { logger } from "../libs/log";
|
import { logger } from "../libs/log";
|
||||||
|
import { sendBgMsg } from "../libs/msg";
|
||||||
|
|
||||||
const SettingContext = createContext({
|
const SettingContext = createContext({
|
||||||
setting: DEFAULT_SETTING,
|
setting: DEFAULT_SETTING,
|
||||||
@@ -30,6 +36,7 @@ export function SettingProvider({ children }) {
|
|||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
logger.setLevel(setting?.logLevel);
|
logger.setLevel(setting?.logLevel);
|
||||||
|
await sendBgMsg(MSG_SET_LOGLEVEL, setting?.logLevel);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error("Failed to fetch log level, using default.", error);
|
logger.error("Failed to fetch log level, using default.", error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user