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