Deploying to gh-pages from @ fishjar/kiss-translator@2a5e9db079 🚀

This commit is contained in:
fishjar
2025-07-23 13:06:19 +00:00
parent 5441473be4
commit 131f3121dd
8 changed files with 31 additions and 31 deletions

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @name KISS Translator
// @namespace https://github.com/fishjar/kiss-translator
// @version 1.9.0
// @version 1.9.1
// @description A simple bilingual translation extension & Greasemonkey script (一个简约的双语对照翻译扩展 & 油猴脚本)
// @author Gabe<yugang2002@gmail.com>
// @homepageURL https://github.com/fishjar/kiss-translator
@@ -30853,7 +30853,7 @@ fetchInterval:DEFAULT_FETCH_INTERVAL,// 任务间隔时间
apiName:OPT_TRANS_GOOGLE,// 接口自定义名称
isDisabled:false,// 是否禁用
httpTimeout:DEFAULT_HTTP_TIMEOUT// 超时时间
},[OPT_TRANS_GOOGLE_2]:{url:URL_GOOGLE_TRAN2,key:DEFAULT_GOOGLE_API_KEY,fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_GOOGLE_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_MICROSOFT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_MICROSOFT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_BAIDU]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_BAIDU,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_TENCENT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_TENCENT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_VOLCENGINE]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_VOLCENGINE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPL]:{url:"https://api-free.deepl.com/v2/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPL,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLFREE]:{fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLFREE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLX]:{url:"http://localhost:1188/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLX,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_NIUTRANS]:{url:"https://api.niutrans.com/NiuTransServer/translation",key:"",dictNo:"",memoryNo:"",fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_NIUTRANS,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_OPENAI]:defaultOpenaiApi,[OPT_TRANS_OPENAI_2]:defaultOpenaiApi,[OPT_TRANS_OPENAI_3]:defaultOpenaiApi,[OPT_TRANS_GEMINI]:{url:"https://generativelanguage.googleapis.com/v1/models/".concat(INPUT_PLACE_MODEL,":generateContent?key=").concat(INPUT_PLACE_KEY),key:"",model:"gemini-2.5-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:2048,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_GEMINI_2]:{url:"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions",key:"",model:"gemini-2.0-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,reasoningEffort:"low",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLAUDE]:{url:"https://api.anthropic.com/v1/messages",key:"",model:"claude-3-haiku-20240307",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:1024,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLAUDE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLOUDFLAREAI]:{url:"https://api.cloudflare.com/client/v4/accounts/{{ACCOUNT_ID}}/ai/run/@cf/meta/m2m100-1.2b",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLOUDFLAREAI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_OLLAMA]:defaultOllamaApi,[OPT_TRANS_OLLAMA_2]:defaultOllamaApi,[OPT_TRANS_OLLAMA_3]:defaultOllamaApi,[OPT_TRANS_CUSTOMIZE]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_2]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_3]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_4]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_5]:defaultCustomApi};// 默认快捷键
},[OPT_TRANS_GOOGLE_2]:{url:URL_GOOGLE_TRAN2,key:DEFAULT_GOOGLE_API_KEY,fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_GOOGLE_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_MICROSOFT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_MICROSOFT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_BAIDU]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_BAIDU,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_TENCENT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_TENCENT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_VOLCENGINE]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_VOLCENGINE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPL]:{url:"https://api-free.deepl.com/v2/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPL,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLFREE]:{fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLFREE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLX]:{url:"http://localhost:1188/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLX,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_NIUTRANS]:{url:"https://api.niutrans.com/NiuTransServer/translation",key:"",dictNo:"",memoryNo:"",fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_NIUTRANS,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_OPENAI]:defaultOpenaiApi,[OPT_TRANS_OPENAI_2]:defaultOpenaiApi,[OPT_TRANS_OPENAI_3]:defaultOpenaiApi,[OPT_TRANS_GEMINI]:{url:"https://generativelanguage.googleapis.com/v1/models/".concat(INPUT_PLACE_MODEL,":generateContent?key=").concat(INPUT_PLACE_KEY),key:"",model:"gemini-2.5-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:2048,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_GEMINI_2]:{url:"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions",key:"",model:"gemini-2.0-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:2048,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLAUDE]:{url:"https://api.anthropic.com/v1/messages",key:"",model:"claude-3-haiku-20240307",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:1024,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLAUDE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLOUDFLAREAI]:{url:"https://api.cloudflare.com/client/v4/accounts/{{ACCOUNT_ID}}/ai/run/@cf/meta/m2m100-1.2b",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLOUDFLAREAI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_OLLAMA]:defaultOllamaApi,[OPT_TRANS_OLLAMA_2]:defaultOllamaApi,[OPT_TRANS_OLLAMA_3]:defaultOllamaApi,[OPT_TRANS_CUSTOMIZE]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_2]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_3]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_4]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_5]:defaultCustomApi};// 默认快捷键
const OPT_SHORTCUT_TRANSLATE="toggleTranslate";const OPT_SHORTCUT_STYLE="toggleStyle";const OPT_SHORTCUT_POPUP="togglePopup";const OPT_SHORTCUT_SETTING="openSetting";const DEFAULT_SHORTCUTS={[OPT_SHORTCUT_TRANSLATE]:["AltLeft","KeyQ"],[OPT_SHORTCUT_STYLE]:["AltLeft","KeyC"],[OPT_SHORTCUT_POPUP]:["AltLeft","KeyK"],[OPT_SHORTCUT_SETTING]:["AltLeft","KeyO"]};const TRANS_MIN_LENGTH=5;// 最短翻译长度
const TRANS_MAX_LENGTH=5000;// 最长翻译长度
const TRANS_NEWLINE_LENGTH=20;// 换行字符数
@@ -31522,7 +31522,7 @@ systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLA
"api-key":key// Azure OpenAI
},method:"POST",body:JSON.stringify(data)};return[url,init];};const genGemini=_ref10=>{let{text,from,to,url,key,systemPrompt,userPrompt,model,temperature,maxTokens}=_ref10;url=url.replaceAll(INPUT_PLACE_MODEL,model).replaceAll(INPUT_PLACE_KEY,key);systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={system_instruction:{parts:{text:systemPrompt}},contents:{role:"user",parts:{text:userPrompt}},generationConfig:{maxOutputTokens:maxTokens,temperature// topP: 0.8,
// topK: 10,
}};const init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};return[url,init];};const genGemini2=_ref11=>{let{text,from,to,url,key,systemPrompt,userPrompt,model,temperature,reasoningEffort}=_ref11;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,reasoning_effort:reasoningEffort,messages:[{role:"system",content:systemPrompt},{role:"user",content:userPrompt}],temperature};const init={headers:{"Content-type":"application/json",Authorization:"Bearer ".concat(key)},method:"POST",body:JSON.stringify(data)};return[url,init];};const genClaude=_ref12=>{let{text,from,to,url,key,systemPrompt,userPrompt,model,temperature,maxTokens}=_ref12;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,system:systemPrompt,messages:[{role:"user",content:userPrompt}],temperature,max_tokens:maxTokens};const init={headers:{"Content-type":"application/json","anthropic-version":"2023-06-01","x-api-key":key},method:"POST",body:JSON.stringify(data)};return[url,init];};const genOllama=_ref13=>{let{text,from,to,think,url,key,systemPrompt,userPrompt,model}=_ref13;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,system:systemPrompt,prompt:userPrompt,think:think,stream:false};const init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};if(key){init.headers.Authorization="Bearer ".concat(key);}return[url,init];};const genCloudflareAI=_ref14=>{let{text,from,to,url,key}=_ref14;const data={text,source_lang:from,target_lang:to};const init={headers:{"Content-type":"application/json",Authorization:"Bearer ".concat(key)},method:"POST",body:JSON.stringify(data)};return[url,init];};const genCustom=_ref15=>{let{text,from,to,url,key,reqHook}=_ref15;url=url.replaceAll(INPUT_PLACE_URL,url).replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text).replaceAll(INPUT_PLACE_KEY,key);let init={};if(reqHook!==null&&reqHook!==void 0&&reqHook.trim()){libs_interpreter.run("exports.reqHook = ".concat(reqHook));[url,init]=libs_interpreter.exports.reqHook(text,from,to,url,key);return[url,init];}const data={text,from,to};init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};if(key){init.headers.Authorization="Bearer ".concat(key);}return[url,init];};/**
}};const init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};return[url,init];};const genGemini2=_ref11=>{let{text,from,to,url,key,systemPrompt,userPrompt,model,temperature,maxTokens}=_ref11;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,messages:[{role:"system",content:systemPrompt},{role:"user",content:userPrompt}],temperature,max_tokens:maxTokens};const init={headers:{"Content-type":"application/json",Authorization:"Bearer ".concat(key)},method:"POST",body:JSON.stringify(data)};return[url,init];};const genClaude=_ref12=>{let{text,from,to,url,key,systemPrompt,userPrompt,model,temperature,maxTokens}=_ref12;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,system:systemPrompt,messages:[{role:"user",content:userPrompt}],temperature,max_tokens:maxTokens};const init={headers:{"Content-type":"application/json","anthropic-version":"2023-06-01","x-api-key":key},method:"POST",body:JSON.stringify(data)};return[url,init];};const genOllama=_ref13=>{let{text,from,to,think,url,key,systemPrompt,userPrompt,model}=_ref13;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,system:systemPrompt,prompt:userPrompt,think:think,stream:false};const init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};if(key){init.headers.Authorization="Bearer ".concat(key);}return[url,init];};const genCloudflareAI=_ref14=>{let{text,from,to,url,key}=_ref14;const data={text,source_lang:from,target_lang:to};const init={headers:{"Content-type":"application/json",Authorization:"Bearer ".concat(key)},method:"POST",body:JSON.stringify(data)};return[url,init];};const genCustom=_ref15=>{let{text,from,to,url,key,reqHook}=_ref15;url=url.replaceAll(INPUT_PLACE_URL,url).replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text).replaceAll(INPUT_PLACE_KEY,key);let init={};if(reqHook!==null&&reqHook!==void 0&&reqHook.trim()){libs_interpreter.run("exports.reqHook = ".concat(reqHook));[url,init]=libs_interpreter.exports.reqHook(text,from,to,url,key);return[url,init];}const data={text,from,to};init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};if(key){init.headers.Authorization="Bearer ".concat(key);}return[url,init];};/**
* 构造翻译接口请求参数
* @param {*}
* @returns
@@ -31734,7 +31734,7 @@ return fetchPolyfill({input,useCache,...args});};/**
* @param {*} param0
* @returns
*/const apiTranslate=async _ref=>{var _OPT_LANGS_SPECIAL$tr,_res$,_res$result,_res$result2,_res$auto_translation,_res$choices,_res$candidates,_res$content,_res$result3;let{translator,text,fromLang,toLang,apiSetting={},useCache=true,usePool=true}=_ref;let trText="";let isSame=false;if(!text){return[trText,true];}const from=(_OPT_LANGS_SPECIAL$tr=OPT_LANGS_SPECIAL[translator].get(fromLang))!==null&&_OPT_LANGS_SPECIAL$tr!==void 0?_OPT_LANGS_SPECIAL$tr:OPT_LANGS_SPECIAL[translator].get("auto");const to=OPT_LANGS_SPECIAL[translator].get(toLang);if(!to){log_kissLog("target lang: ".concat(toLang," not support"),"translate");return[trText,isSame];}// 版本号一/二位升级旧缓存失效
const[v1,v2]="1.9.0".split(".");const cacheOpts={translator,text,fromLang,toLang,version:[v1,v2].join(".")};const transOpts={translator,text,from,to};const res=await fetchData("".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts)),{useCache,usePool,transOpts,apiSetting});switch(translator){case OPT_TRANS_GOOGLE:trText=res.sentences.map(item=>item.trans).join(" ");isSame=to===res.src;break;case OPT_TRANS_GOOGLE_2:trText=(res===null||res===void 0?void 0:(_res$=res[0])===null||_res$===void 0?void 0:_res$[0])||"";isSame=to===res.src;break;case OPT_TRANS_MICROSOFT:trText=res.map(item=>item.translations.map(item=>item.text).join(" ")).join(" ");isSame=text===trText;break;case OPT_TRANS_DEEPL:trText=res.translations.map(item=>item.text).join(" ");isSame=to===res.translations[0].detected_source_language;break;case OPT_TRANS_DEEPLFREE:trText=(_res$result=res.result)===null||_res$result===void 0?void 0:_res$result.texts.map(item=>item.text).join(" ");isSame=to===((_res$result2=res.result)===null||_res$result2===void 0?void 0:_res$result2.lang);break;case OPT_TRANS_DEEPLX:trText=res.data;isSame=to===res.source_lang;break;case OPT_TRANS_NIUTRANS:const json=JSON.parse(res);if(json.error_msg){throw new Error(json.error_msg);}trText=json.tgt_text;isSame=to===json.from;break;case OPT_TRANS_BAIDU:// trText = res.trans_result?.data.map((item) => item.dst).join(" ");
const[v1,v2]="1.9.1".split(".");const cacheOpts={translator,text,fromLang,toLang,version:[v1,v2].join(".")};const transOpts={translator,text,from,to};const res=await fetchData("".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts)),{useCache,usePool,transOpts,apiSetting});switch(translator){case OPT_TRANS_GOOGLE:trText=res.sentences.map(item=>item.trans).join(" ");isSame=to===res.src;break;case OPT_TRANS_GOOGLE_2:trText=(res===null||res===void 0?void 0:(_res$=res[0])===null||_res$===void 0?void 0:_res$[0])||"";isSame=to===res.src;break;case OPT_TRANS_MICROSOFT:trText=res.map(item=>item.translations.map(item=>item.text).join(" ")).join(" ");isSame=text===trText;break;case OPT_TRANS_DEEPL:trText=res.translations.map(item=>item.text).join(" ");isSame=to===res.translations[0].detected_source_language;break;case OPT_TRANS_DEEPLFREE:trText=(_res$result=res.result)===null||_res$result===void 0?void 0:_res$result.texts.map(item=>item.text).join(" ");isSame=to===((_res$result2=res.result)===null||_res$result2===void 0?void 0:_res$result2.lang);break;case OPT_TRANS_DEEPLX:trText=res.data;isSame=to===res.source_lang;break;case OPT_TRANS_NIUTRANS:const json=JSON.parse(res);if(json.error_msg){throw new Error(json.error_msg);}trText=json.tgt_text;isSame=to===json.from;break;case OPT_TRANS_BAIDU:// trText = res.trans_result?.data.map((item) => item.dst).join(" ");
// isSame = res.trans_result?.to === res.trans_result?.from;
if(res.type===1){trText=Object.keys(JSON.parse(res.result).content[0].mean[0].cont)[0];isSame=to===res.from;}else if(res.type===2){trText=res.data.map(item=>item.dst).join(" ");isSame=to===res.from;}break;case OPT_TRANS_TENCENT:trText=res===null||res===void 0?void 0:(_res$auto_translation=res.auto_translation)===null||_res$auto_translation===void 0?void 0:_res$auto_translation[0];isSame=text===trText;break;case OPT_TRANS_VOLCENGINE:trText=(res===null||res===void 0?void 0:res.translation)||"";isSame=to===(res===null||res===void 0?void 0:res.detected_language);break;case OPT_TRANS_OPENAI:case OPT_TRANS_OPENAI_2:case OPT_TRANS_OPENAI_3:case OPT_TRANS_GEMINI_2:trText=res===null||res===void 0?void 0:(_res$choices=res.choices)===null||_res$choices===void 0?void 0:_res$choices.map(item=>item.message.content).join(" ");isSame=text===trText;break;case OPT_TRANS_GEMINI:trText=res===null||res===void 0?void 0:(_res$candidates=res.candidates)===null||_res$candidates===void 0?void 0:_res$candidates.map(item=>{var _item$content;return(_item$content=item.content)===null||_item$content===void 0?void 0:_item$content.parts.map(item=>item.text).join(" ");}).join(" ");isSame=text===trText;break;case OPT_TRANS_CLAUDE:trText=res===null||res===void 0?void 0:(_res$content=res.content)===null||_res$content===void 0?void 0:_res$content.map(item=>item.text).join(" ");isSame=text===trText;break;case OPT_TRANS_CLOUDFLAREAI:trText=res===null||res===void 0?void 0:(_res$result3=res.result)===null||_res$result3===void 0?void 0:_res$result3.translated_text;isSame=text===trText;break;case OPT_TRANS_OLLAMA:case OPT_TRANS_OLLAMA_2:case OPT_TRANS_OLLAMA_3:const{thinkIgnore=""}=apiSetting;const deepModels=thinkIgnore.split(",").filter(model=>model.trim());if(deepModels.some(model=>{var _res$model;return res===null||res===void 0?void 0:(_res$model=res.model)===null||_res$model===void 0?void 0:_res$model.startsWith(model);})){trText=res===null||res===void 0?void 0:res.response.replace(/<think>[\s\S]*<\/think>/i,"");}else{trText=res===null||res===void 0?void 0:res.response;}isSame=text===trText;break;case OPT_TRANS_CUSTOMIZE:case OPT_TRANS_CUSTOMIZE_2:case OPT_TRANS_CUSTOMIZE_3:case OPT_TRANS_CUSTOMIZE_4:case OPT_TRANS_CUSTOMIZE_5:const{resHook}=apiSetting;if(resHook!==null&&resHook!==void 0&&resHook.trim()){libs_interpreter.run("exports.resHook = ".concat(resHook));[trText,isSame]=libs_interpreter.exports.resHook(res,text,from,to);}else{trText=res.text;isSame=to===res.from;}break;default:}return[trText,isSame,res];};
;// CONCATENATED MODULE: ./node_modules/.pnpm/webdav@5.3.0/node_modules/webdav/dist/web/index.js
@@ -34549,7 +34549,7 @@ var n = {};
return t.length === e && "." !== t && ".." !== t;
};
},
te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.0","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.0","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.0","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.1","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.1","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.1","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
It.sep = "win32" === te ? "\\" : "/";
var ee = Symbol("globstar **");
It.GLOBSTAR = ee;
@@ -44832,7 +44832,7 @@ var DarkMode = __webpack_require__(7415);
;// CONCATENATED MODULE: ./src/views/Options/DarkModeButton.js
function DarkModeButton(){const{darkMode,toggleDarkMode}=useDarkMode();return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:toggleDarkMode,color:"inherit",children:darkMode?/*#__PURE__*/(0,jsx_runtime.jsx)(LightMode/* default */.Z,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(DarkMode/* default */.Z,{})});}
;// CONCATENATED MODULE: ./src/views/Popup/Header.js
function Header(_ref){let{setShowPopup}=_ref;const handleHomepage=()=>{window.open("https://github.com/fishjar/kiss-translator","_blank");};return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"flex-start",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:handleHomepage,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Home/* default */.Z,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("1.9.0")})]}),setShowPopup?/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:()=>{setShowPopup(false);},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Close/* default */.Z,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]});}
function Header(_ref){let{setShowPopup}=_ref;const handleHomepage=()=>{window.open("https://github.com/fishjar/kiss-translator","_blank");};return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"flex-start",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:handleHomepage,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Home/* default */.Z,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("1.9.1")})]}),setShowPopup?/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:()=>{setShowPopup(false);},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Close/* default */.Z,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]});}
;// CONCATENATED MODULE: ./src/libs/iframe.js
const isIframe=window.self!==window.top;const sendIframeMsg=(action,args)=>{document.querySelectorAll("iframe").forEach(iframe=>{iframe.contentWindow.postMessage({action,args},"*");});};const sendParentMsg=(action,args)=>{window.parent.postMessage({action,args},"*");};
;// CONCATENATED MODULE: ./src/libs/subRules.js
@@ -46143,7 +46143,7 @@ function touchTapListener(fn,touchsLength){const handleTouchend=e=>{if(e.touches
const MSG_GM_xmlHttpRequest="xmlHttpRequest";const MSG_GM_setValue="setValue";const MSG_GM_getValue="getValue";const MSG_GM_deleteValue="deleteValue";const MSG_GM_info="info";/**
* 注入页面的脚本请求并接受GM接口信息
* @param {*} param0
*/const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"1.9.0",eventName:ping};};/**
*/const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"1.9.1",eventName:ping};};/**
* 适配GM脚本
*/const adaptScript=ping=>{const promiseGM=function(action,args){let timeout=arguments.length>2&&arguments[2]!==undefined?arguments[2]:5000;return new Promise((resolve,reject)=>{const pong=genEventName();const handleEvent=e=>{window.removeEventListener(pong,handleEvent);const{data,error}=e.detail;if(error){reject(new Error(error));}else{resolve(data);}};window.addEventListener(pong,handleEvent);window.dispatchEvent(new CustomEvent(ping,{detail:{action,args,pong}}));setTimeout(()=>{window.removeEventListener(pong,handleEvent);reject(new Error("timeout"));},timeout);});};window.KISS_GM={fetch:(input,init)=>promiseGM(MSG_GM_xmlHttpRequest,{input,init}),setValue:(key,val)=>promiseGM(MSG_GM_setValue,{key,val}),getValue:key=>promiseGM(MSG_GM_getValue,{key}),deleteValue:key=>promiseGM(MSG_GM_deleteValue,{key}),getInfo:async()=>{if(!window.GM_info){window.GM_info=await promiseGM(MSG_GM_info);}return window.GM_info;}};};/**
* 监听并回应页面对GM接口的请求
@@ -46166,7 +46166,7 @@ if(getNodeText(node).startsWith(initText)){pasteContentCommand(node,trText);awai
;// CONCATENATED MODULE: ./src/common.js
/**
* 油猴脚本设置页面
*/function runSettingPage(){var _GM,_GM$info,_GM$info$script,_GM$info$script$grant;if((_GM=GM)!==null&&_GM!==void 0&&(_GM$info=_GM.info)!==null&&_GM$info!==void 0&&(_GM$info$script=_GM$info.script)!==null&&_GM$info$script!==void 0&&(_GM$info$script$grant=_GM$info$script.grant)!==null&&_GM$info$script$grant!==void 0&&_GM$info$script$grant.includes("unsafeWindow")){unsafeWindow.GM=GM;unsafeWindow.APP_INFO={name:"KISS Translator",version:"1.9.0"};}else{const ping=utils_genEventName();window.addEventListener(ping,handlePing);// window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line
*/function runSettingPage(){var _GM,_GM$info,_GM$info$script,_GM$info$script$grant;if((_GM=GM)!==null&&_GM!==void 0&&(_GM$info=_GM.info)!==null&&_GM$info!==void 0&&(_GM$info$script=_GM$info.script)!==null&&_GM$info$script!==void 0&&(_GM$info$script$grant=_GM$info$script.grant)!==null&&_GM$info$script$grant!==void 0&&_GM$info$script$grant.includes("unsafeWindow")){unsafeWindow.GM=GM;unsafeWindow.APP_INFO={name:"KISS Translator",version:"1.9.1"};}else{const ping=utils_genEventName();window.addEventListener(ping,handlePing);// window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line
const script=document.createElement("script");script.textContent="(".concat(injectScript,")(\"").concat(ping,"\")");document.head.append(script);}}/**
* 插件监听后端事件
* @param {*} translator

View File

@@ -1,7 +1,7 @@
// ==UserScript==
// @name KISS Translator
// @namespace https://github.com/fishjar/kiss-translator
// @version 1.9.0
// @version 1.9.1
// @description A simple bilingual translation extension & Greasemonkey script (一个简约的双语对照翻译扩展 & 油猴脚本)
// @author Gabe<yugang2002@gmail.com>
// @homepageURL https://github.com/fishjar/kiss-translator
@@ -30853,7 +30853,7 @@ fetchInterval:DEFAULT_FETCH_INTERVAL,// 任务间隔时间
apiName:OPT_TRANS_GOOGLE,// 接口自定义名称
isDisabled:false,// 是否禁用
httpTimeout:DEFAULT_HTTP_TIMEOUT// 超时时间
},[OPT_TRANS_GOOGLE_2]:{url:URL_GOOGLE_TRAN2,key:DEFAULT_GOOGLE_API_KEY,fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_GOOGLE_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_MICROSOFT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_MICROSOFT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_BAIDU]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_BAIDU,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_TENCENT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_TENCENT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_VOLCENGINE]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_VOLCENGINE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPL]:{url:"https://api-free.deepl.com/v2/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPL,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLFREE]:{fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLFREE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLX]:{url:"http://localhost:1188/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLX,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_NIUTRANS]:{url:"https://api.niutrans.com/NiuTransServer/translation",key:"",dictNo:"",memoryNo:"",fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_NIUTRANS,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_OPENAI]:defaultOpenaiApi,[OPT_TRANS_OPENAI_2]:defaultOpenaiApi,[OPT_TRANS_OPENAI_3]:defaultOpenaiApi,[OPT_TRANS_GEMINI]:{url:"https://generativelanguage.googleapis.com/v1/models/".concat(INPUT_PLACE_MODEL,":generateContent?key=").concat(INPUT_PLACE_KEY),key:"",model:"gemini-2.5-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:2048,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_GEMINI_2]:{url:"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions",key:"",model:"gemini-2.0-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,reasoningEffort:"low",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLAUDE]:{url:"https://api.anthropic.com/v1/messages",key:"",model:"claude-3-haiku-20240307",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:1024,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLAUDE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLOUDFLAREAI]:{url:"https://api.cloudflare.com/client/v4/accounts/{{ACCOUNT_ID}}/ai/run/@cf/meta/m2m100-1.2b",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLOUDFLAREAI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_OLLAMA]:defaultOllamaApi,[OPT_TRANS_OLLAMA_2]:defaultOllamaApi,[OPT_TRANS_OLLAMA_3]:defaultOllamaApi,[OPT_TRANS_CUSTOMIZE]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_2]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_3]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_4]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_5]:defaultCustomApi};// 默认快捷键
},[OPT_TRANS_GOOGLE_2]:{url:URL_GOOGLE_TRAN2,key:DEFAULT_GOOGLE_API_KEY,fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_GOOGLE_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_MICROSOFT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_MICROSOFT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_BAIDU]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_BAIDU,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_TENCENT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_TENCENT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_VOLCENGINE]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_VOLCENGINE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPL]:{url:"https://api-free.deepl.com/v2/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPL,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLFREE]:{fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLFREE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLX]:{url:"http://localhost:1188/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLX,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_NIUTRANS]:{url:"https://api.niutrans.com/NiuTransServer/translation",key:"",dictNo:"",memoryNo:"",fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_NIUTRANS,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_OPENAI]:defaultOpenaiApi,[OPT_TRANS_OPENAI_2]:defaultOpenaiApi,[OPT_TRANS_OPENAI_3]:defaultOpenaiApi,[OPT_TRANS_GEMINI]:{url:"https://generativelanguage.googleapis.com/v1/models/".concat(INPUT_PLACE_MODEL,":generateContent?key=").concat(INPUT_PLACE_KEY),key:"",model:"gemini-2.5-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:2048,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_GEMINI_2]:{url:"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions",key:"",model:"gemini-2.0-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:2048,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLAUDE]:{url:"https://api.anthropic.com/v1/messages",key:"",model:"claude-3-haiku-20240307",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:1024,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLAUDE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLOUDFLAREAI]:{url:"https://api.cloudflare.com/client/v4/accounts/{{ACCOUNT_ID}}/ai/run/@cf/meta/m2m100-1.2b",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLOUDFLAREAI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_OLLAMA]:defaultOllamaApi,[OPT_TRANS_OLLAMA_2]:defaultOllamaApi,[OPT_TRANS_OLLAMA_3]:defaultOllamaApi,[OPT_TRANS_CUSTOMIZE]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_2]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_3]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_4]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_5]:defaultCustomApi};// 默认快捷键
const OPT_SHORTCUT_TRANSLATE="toggleTranslate";const OPT_SHORTCUT_STYLE="toggleStyle";const OPT_SHORTCUT_POPUP="togglePopup";const OPT_SHORTCUT_SETTING="openSetting";const DEFAULT_SHORTCUTS={[OPT_SHORTCUT_TRANSLATE]:["AltLeft","KeyQ"],[OPT_SHORTCUT_STYLE]:["AltLeft","KeyC"],[OPT_SHORTCUT_POPUP]:["AltLeft","KeyK"],[OPT_SHORTCUT_SETTING]:["AltLeft","KeyO"]};const TRANS_MIN_LENGTH=5;// 最短翻译长度
const TRANS_MAX_LENGTH=5000;// 最长翻译长度
const TRANS_NEWLINE_LENGTH=20;// 换行字符数
@@ -31522,7 +31522,7 @@ systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLA
"api-key":key// Azure OpenAI
},method:"POST",body:JSON.stringify(data)};return[url,init];};const genGemini=_ref10=>{let{text,from,to,url,key,systemPrompt,userPrompt,model,temperature,maxTokens}=_ref10;url=url.replaceAll(INPUT_PLACE_MODEL,model).replaceAll(INPUT_PLACE_KEY,key);systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={system_instruction:{parts:{text:systemPrompt}},contents:{role:"user",parts:{text:userPrompt}},generationConfig:{maxOutputTokens:maxTokens,temperature// topP: 0.8,
// topK: 10,
}};const init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};return[url,init];};const genGemini2=_ref11=>{let{text,from,to,url,key,systemPrompt,userPrompt,model,temperature,reasoningEffort}=_ref11;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,reasoning_effort:reasoningEffort,messages:[{role:"system",content:systemPrompt},{role:"user",content:userPrompt}],temperature};const init={headers:{"Content-type":"application/json",Authorization:"Bearer ".concat(key)},method:"POST",body:JSON.stringify(data)};return[url,init];};const genClaude=_ref12=>{let{text,from,to,url,key,systemPrompt,userPrompt,model,temperature,maxTokens}=_ref12;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,system:systemPrompt,messages:[{role:"user",content:userPrompt}],temperature,max_tokens:maxTokens};const init={headers:{"Content-type":"application/json","anthropic-version":"2023-06-01","x-api-key":key},method:"POST",body:JSON.stringify(data)};return[url,init];};const genOllama=_ref13=>{let{text,from,to,think,url,key,systemPrompt,userPrompt,model}=_ref13;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,system:systemPrompt,prompt:userPrompt,think:think,stream:false};const init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};if(key){init.headers.Authorization="Bearer ".concat(key);}return[url,init];};const genCloudflareAI=_ref14=>{let{text,from,to,url,key}=_ref14;const data={text,source_lang:from,target_lang:to};const init={headers:{"Content-type":"application/json",Authorization:"Bearer ".concat(key)},method:"POST",body:JSON.stringify(data)};return[url,init];};const genCustom=_ref15=>{let{text,from,to,url,key,reqHook}=_ref15;url=url.replaceAll(INPUT_PLACE_URL,url).replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text).replaceAll(INPUT_PLACE_KEY,key);let init={};if(reqHook!==null&&reqHook!==void 0&&reqHook.trim()){libs_interpreter.run("exports.reqHook = ".concat(reqHook));[url,init]=libs_interpreter.exports.reqHook(text,from,to,url,key);return[url,init];}const data={text,from,to};init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};if(key){init.headers.Authorization="Bearer ".concat(key);}return[url,init];};/**
}};const init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};return[url,init];};const genGemini2=_ref11=>{let{text,from,to,url,key,systemPrompt,userPrompt,model,temperature,maxTokens}=_ref11;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,messages:[{role:"system",content:systemPrompt},{role:"user",content:userPrompt}],temperature,max_tokens:maxTokens};const init={headers:{"Content-type":"application/json",Authorization:"Bearer ".concat(key)},method:"POST",body:JSON.stringify(data)};return[url,init];};const genClaude=_ref12=>{let{text,from,to,url,key,systemPrompt,userPrompt,model,temperature,maxTokens}=_ref12;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,system:systemPrompt,messages:[{role:"user",content:userPrompt}],temperature,max_tokens:maxTokens};const init={headers:{"Content-type":"application/json","anthropic-version":"2023-06-01","x-api-key":key},method:"POST",body:JSON.stringify(data)};return[url,init];};const genOllama=_ref13=>{let{text,from,to,think,url,key,systemPrompt,userPrompt,model}=_ref13;systemPrompt=systemPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);userPrompt=userPrompt.replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text);const data={model,system:systemPrompt,prompt:userPrompt,think:think,stream:false};const init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};if(key){init.headers.Authorization="Bearer ".concat(key);}return[url,init];};const genCloudflareAI=_ref14=>{let{text,from,to,url,key}=_ref14;const data={text,source_lang:from,target_lang:to};const init={headers:{"Content-type":"application/json",Authorization:"Bearer ".concat(key)},method:"POST",body:JSON.stringify(data)};return[url,init];};const genCustom=_ref15=>{let{text,from,to,url,key,reqHook}=_ref15;url=url.replaceAll(INPUT_PLACE_URL,url).replaceAll(INPUT_PLACE_FROM,from).replaceAll(INPUT_PLACE_TO,to).replaceAll(INPUT_PLACE_TEXT,text).replaceAll(INPUT_PLACE_KEY,key);let init={};if(reqHook!==null&&reqHook!==void 0&&reqHook.trim()){libs_interpreter.run("exports.reqHook = ".concat(reqHook));[url,init]=libs_interpreter.exports.reqHook(text,from,to,url,key);return[url,init];}const data={text,from,to};init={headers:{"Content-type":"application/json"},method:"POST",body:JSON.stringify(data)};if(key){init.headers.Authorization="Bearer ".concat(key);}return[url,init];};/**
* 构造翻译接口请求参数
* @param {*}
* @returns
@@ -31734,7 +31734,7 @@ return fetchPolyfill({input,useCache,...args});};/**
* @param {*} param0
* @returns
*/const apiTranslate=async _ref=>{var _OPT_LANGS_SPECIAL$tr,_res$,_res$result,_res$result2,_res$auto_translation,_res$choices,_res$candidates,_res$content,_res$result3;let{translator,text,fromLang,toLang,apiSetting={},useCache=true,usePool=true}=_ref;let trText="";let isSame=false;if(!text){return[trText,true];}const from=(_OPT_LANGS_SPECIAL$tr=OPT_LANGS_SPECIAL[translator].get(fromLang))!==null&&_OPT_LANGS_SPECIAL$tr!==void 0?_OPT_LANGS_SPECIAL$tr:OPT_LANGS_SPECIAL[translator].get("auto");const to=OPT_LANGS_SPECIAL[translator].get(toLang);if(!to){log_kissLog("target lang: ".concat(toLang," not support"),"translate");return[trText,isSame];}// 版本号一/二位升级旧缓存失效
const[v1,v2]="1.9.0".split(".");const cacheOpts={translator,text,fromLang,toLang,version:[v1,v2].join(".")};const transOpts={translator,text,from,to};const res=await fetchData("".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts)),{useCache,usePool,transOpts,apiSetting});switch(translator){case OPT_TRANS_GOOGLE:trText=res.sentences.map(item=>item.trans).join(" ");isSame=to===res.src;break;case OPT_TRANS_GOOGLE_2:trText=(res===null||res===void 0?void 0:(_res$=res[0])===null||_res$===void 0?void 0:_res$[0])||"";isSame=to===res.src;break;case OPT_TRANS_MICROSOFT:trText=res.map(item=>item.translations.map(item=>item.text).join(" ")).join(" ");isSame=text===trText;break;case OPT_TRANS_DEEPL:trText=res.translations.map(item=>item.text).join(" ");isSame=to===res.translations[0].detected_source_language;break;case OPT_TRANS_DEEPLFREE:trText=(_res$result=res.result)===null||_res$result===void 0?void 0:_res$result.texts.map(item=>item.text).join(" ");isSame=to===((_res$result2=res.result)===null||_res$result2===void 0?void 0:_res$result2.lang);break;case OPT_TRANS_DEEPLX:trText=res.data;isSame=to===res.source_lang;break;case OPT_TRANS_NIUTRANS:const json=JSON.parse(res);if(json.error_msg){throw new Error(json.error_msg);}trText=json.tgt_text;isSame=to===json.from;break;case OPT_TRANS_BAIDU:// trText = res.trans_result?.data.map((item) => item.dst).join(" ");
const[v1,v2]="1.9.1".split(".");const cacheOpts={translator,text,fromLang,toLang,version:[v1,v2].join(".")};const transOpts={translator,text,from,to};const res=await fetchData("".concat(URL_CACHE_TRAN,"?").concat(query_string.stringify(cacheOpts)),{useCache,usePool,transOpts,apiSetting});switch(translator){case OPT_TRANS_GOOGLE:trText=res.sentences.map(item=>item.trans).join(" ");isSame=to===res.src;break;case OPT_TRANS_GOOGLE_2:trText=(res===null||res===void 0?void 0:(_res$=res[0])===null||_res$===void 0?void 0:_res$[0])||"";isSame=to===res.src;break;case OPT_TRANS_MICROSOFT:trText=res.map(item=>item.translations.map(item=>item.text).join(" ")).join(" ");isSame=text===trText;break;case OPT_TRANS_DEEPL:trText=res.translations.map(item=>item.text).join(" ");isSame=to===res.translations[0].detected_source_language;break;case OPT_TRANS_DEEPLFREE:trText=(_res$result=res.result)===null||_res$result===void 0?void 0:_res$result.texts.map(item=>item.text).join(" ");isSame=to===((_res$result2=res.result)===null||_res$result2===void 0?void 0:_res$result2.lang);break;case OPT_TRANS_DEEPLX:trText=res.data;isSame=to===res.source_lang;break;case OPT_TRANS_NIUTRANS:const json=JSON.parse(res);if(json.error_msg){throw new Error(json.error_msg);}trText=json.tgt_text;isSame=to===json.from;break;case OPT_TRANS_BAIDU:// trText = res.trans_result?.data.map((item) => item.dst).join(" ");
// isSame = res.trans_result?.to === res.trans_result?.from;
if(res.type===1){trText=Object.keys(JSON.parse(res.result).content[0].mean[0].cont)[0];isSame=to===res.from;}else if(res.type===2){trText=res.data.map(item=>item.dst).join(" ");isSame=to===res.from;}break;case OPT_TRANS_TENCENT:trText=res===null||res===void 0?void 0:(_res$auto_translation=res.auto_translation)===null||_res$auto_translation===void 0?void 0:_res$auto_translation[0];isSame=text===trText;break;case OPT_TRANS_VOLCENGINE:trText=(res===null||res===void 0?void 0:res.translation)||"";isSame=to===(res===null||res===void 0?void 0:res.detected_language);break;case OPT_TRANS_OPENAI:case OPT_TRANS_OPENAI_2:case OPT_TRANS_OPENAI_3:case OPT_TRANS_GEMINI_2:trText=res===null||res===void 0?void 0:(_res$choices=res.choices)===null||_res$choices===void 0?void 0:_res$choices.map(item=>item.message.content).join(" ");isSame=text===trText;break;case OPT_TRANS_GEMINI:trText=res===null||res===void 0?void 0:(_res$candidates=res.candidates)===null||_res$candidates===void 0?void 0:_res$candidates.map(item=>{var _item$content;return(_item$content=item.content)===null||_item$content===void 0?void 0:_item$content.parts.map(item=>item.text).join(" ");}).join(" ");isSame=text===trText;break;case OPT_TRANS_CLAUDE:trText=res===null||res===void 0?void 0:(_res$content=res.content)===null||_res$content===void 0?void 0:_res$content.map(item=>item.text).join(" ");isSame=text===trText;break;case OPT_TRANS_CLOUDFLAREAI:trText=res===null||res===void 0?void 0:(_res$result3=res.result)===null||_res$result3===void 0?void 0:_res$result3.translated_text;isSame=text===trText;break;case OPT_TRANS_OLLAMA:case OPT_TRANS_OLLAMA_2:case OPT_TRANS_OLLAMA_3:const{thinkIgnore=""}=apiSetting;const deepModels=thinkIgnore.split(",").filter(model=>model.trim());if(deepModels.some(model=>{var _res$model;return res===null||res===void 0?void 0:(_res$model=res.model)===null||_res$model===void 0?void 0:_res$model.startsWith(model);})){trText=res===null||res===void 0?void 0:res.response.replace(/<think>[\s\S]*<\/think>/i,"");}else{trText=res===null||res===void 0?void 0:res.response;}isSame=text===trText;break;case OPT_TRANS_CUSTOMIZE:case OPT_TRANS_CUSTOMIZE_2:case OPT_TRANS_CUSTOMIZE_3:case OPT_TRANS_CUSTOMIZE_4:case OPT_TRANS_CUSTOMIZE_5:const{resHook}=apiSetting;if(resHook!==null&&resHook!==void 0&&resHook.trim()){libs_interpreter.run("exports.resHook = ".concat(resHook));[trText,isSame]=libs_interpreter.exports.resHook(res,text,from,to);}else{trText=res.text;isSame=to===res.from;}break;default:}return[trText,isSame,res];};
;// CONCATENATED MODULE: ./node_modules/.pnpm/webdav@5.3.0/node_modules/webdav/dist/web/index.js
@@ -34549,7 +34549,7 @@ var n = {};
return t.length === e && "." !== t && ".." !== t;
};
},
te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.0","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.0","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.0","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
te = "object" === ("undefined" == typeof process ? "undefined" : Nt(process)) && process ? "object" === Nt(({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.1","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"})) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.1","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}) && ({"NODE_ENV":"production","PUBLIC_URL":"","WDS_SOCKET_HOST":undefined,"WDS_SOCKET_PATH":undefined,"WDS_SOCKET_PORT":undefined,"FAST_REFRESH":true,"REACT_APP_CLIENT":"userscript","REACT_APP_NAME":"KISS Translator","REACT_APP_NAME_CN":"简约翻译","REACT_APP_VERSION":"1.9.1","REACT_APP_HOMEPAGE":"https://github.com/fishjar/kiss-translator","REACT_APP_OPTIONSPAGE":"https://fishjar.github.io/kiss-translator/options.html","REACT_APP_OPTIONSPAGE_DEV":"http://localhost:3000/options.html","REACT_APP_LOGOURL":"https://fishjar.github.io/kiss-translator/images/logo192.png","REACT_APP_RULESURL":"https://fishjar.github.io/kiss-rules/kiss-rules.json","REACT_APP_RULESURL_ON":"https://fishjar.github.io/kiss-rules/kiss-rules-on.json","REACT_APP_RULESURL_OFF":"https://fishjar.github.io/kiss-rules/kiss-rules-off.json","REACT_APP_USERSCRIPT_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator.user.js","REACT_APP_USERSCRIPT_IOS_DOWNLOADURL":"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js"}).__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
It.sep = "win32" === te ? "\\" : "/";
var ee = Symbol("globstar **");
It.GLOBSTAR = ee;
@@ -44832,7 +44832,7 @@ var DarkMode = __webpack_require__(7415);
;// CONCATENATED MODULE: ./src/views/Options/DarkModeButton.js
function DarkModeButton(){const{darkMode,toggleDarkMode}=useDarkMode();return/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:toggleDarkMode,color:"inherit",children:darkMode?/*#__PURE__*/(0,jsx_runtime.jsx)(LightMode/* default */.Z,{}):/*#__PURE__*/(0,jsx_runtime.jsx)(DarkMode/* default */.Z,{})});}
;// CONCATENATED MODULE: ./src/views/Popup/Header.js
function Header(_ref){let{setShowPopup}=_ref;const handleHomepage=()=>{window.open("https://github.com/fishjar/kiss-translator","_blank");};return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"flex-start",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:handleHomepage,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Home/* default */.Z,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("1.9.0")})]}),setShowPopup?/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:()=>{setShowPopup(false);},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Close/* default */.Z,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]});}
function Header(_ref){let{setShowPopup}=_ref;const handleHomepage=()=>{window.open("https://github.com/fishjar/kiss-translator","_blank");};return/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{direction:"row",justifyContent:"flex-start",alignItems:"center",children:[/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:handleHomepage,children:/*#__PURE__*/(0,jsx_runtime.jsx)(Home/* default */.Z,{})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Typography_Typography,{component:"div",sx:{userSelect:"none",WebkitUserSelect:"none",fontWeight:"bold"},children:"".concat("KISS Translator"," v").concat("1.9.1")})]}),setShowPopup?/*#__PURE__*/(0,jsx_runtime.jsx)(IconButton_IconButton,{onClick:()=>{setShowPopup(false);},children:/*#__PURE__*/(0,jsx_runtime.jsx)(Close/* default */.Z,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(DarkModeButton,{})]});}
;// CONCATENATED MODULE: ./src/libs/iframe.js
const isIframe=window.self!==window.top;const sendIframeMsg=(action,args)=>{document.querySelectorAll("iframe").forEach(iframe=>{iframe.contentWindow.postMessage({action,args},"*");});};const sendParentMsg=(action,args)=>{window.parent.postMessage({action,args},"*");};
;// CONCATENATED MODULE: ./src/libs/subRules.js
@@ -46143,7 +46143,7 @@ function touchTapListener(fn,touchsLength){const handleTouchend=e=>{if(e.touches
const MSG_GM_xmlHttpRequest="xmlHttpRequest";const MSG_GM_setValue="setValue";const MSG_GM_getValue="getValue";const MSG_GM_deleteValue="deleteValue";const MSG_GM_info="info";/**
* 注入页面的脚本请求并接受GM接口信息
* @param {*} param0
*/const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"1.9.0",eventName:ping};};/**
*/const injectScript=ping=>{window.APP_INFO={name:"KISS Translator",version:"1.9.1",eventName:ping};};/**
* 适配GM脚本
*/const adaptScript=ping=>{const promiseGM=function(action,args){let timeout=arguments.length>2&&arguments[2]!==undefined?arguments[2]:5000;return new Promise((resolve,reject)=>{const pong=genEventName();const handleEvent=e=>{window.removeEventListener(pong,handleEvent);const{data,error}=e.detail;if(error){reject(new Error(error));}else{resolve(data);}};window.addEventListener(pong,handleEvent);window.dispatchEvent(new CustomEvent(ping,{detail:{action,args,pong}}));setTimeout(()=>{window.removeEventListener(pong,handleEvent);reject(new Error("timeout"));},timeout);});};window.KISS_GM={fetch:(input,init)=>promiseGM(MSG_GM_xmlHttpRequest,{input,init}),setValue:(key,val)=>promiseGM(MSG_GM_setValue,{key,val}),getValue:key=>promiseGM(MSG_GM_getValue,{key}),deleteValue:key=>promiseGM(MSG_GM_deleteValue,{key}),getInfo:async()=>{if(!window.GM_info){window.GM_info=await promiseGM(MSG_GM_info);}return window.GM_info;}};};/**
* 监听并回应页面对GM接口的请求
@@ -46166,7 +46166,7 @@ if(getNodeText(node).startsWith(initText)){pasteContentCommand(node,trText);awai
;// CONCATENATED MODULE: ./src/common.js
/**
* 油猴脚本设置页面
*/function runSettingPage(){var _GM,_GM$info,_GM$info$script,_GM$info$script$grant;if((_GM=GM)!==null&&_GM!==void 0&&(_GM$info=_GM.info)!==null&&_GM$info!==void 0&&(_GM$info$script=_GM$info.script)!==null&&_GM$info$script!==void 0&&(_GM$info$script$grant=_GM$info$script.grant)!==null&&_GM$info$script$grant!==void 0&&_GM$info$script$grant.includes("unsafeWindow")){unsafeWindow.GM=GM;unsafeWindow.APP_INFO={name:"KISS Translator",version:"1.9.0"};}else{const ping=utils_genEventName();window.addEventListener(ping,handlePing);// window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line
*/function runSettingPage(){var _GM,_GM$info,_GM$info$script,_GM$info$script$grant;if((_GM=GM)!==null&&_GM!==void 0&&(_GM$info=_GM.info)!==null&&_GM$info!==void 0&&(_GM$info$script=_GM$info.script)!==null&&_GM$info$script!==void 0&&(_GM$info$script$grant=_GM$info$script.grant)!==null&&_GM$info$script$grant!==void 0&&_GM$info$script$grant.includes("unsafeWindow")){unsafeWindow.GM=GM;unsafeWindow.APP_INFO={name:"KISS Translator",version:"1.9.1"};}else{const ping=utils_genEventName();window.addEventListener(ping,handlePing);// window.eval(`(${injectScript})("${ping}")`); // eslint-disable-line
const script=document.createElement("script");script.textContent="(".concat(injectScript,")(\"").concat(ping,"\")");document.head.append(script);}}/**
* 插件监听后端事件
* @param {*} translator

View File

@@ -34820,7 +34820,7 @@ fetchInterval:DEFAULT_FETCH_INTERVAL,// 任务间隔时间
apiName:OPT_TRANS_GOOGLE,// 接口自定义名称
isDisabled:false,// 是否禁用
httpTimeout:DEFAULT_HTTP_TIMEOUT// 超时时间
},[OPT_TRANS_GOOGLE_2]:{url:URL_GOOGLE_TRAN2,key:DEFAULT_GOOGLE_API_KEY,fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_GOOGLE_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_MICROSOFT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_MICROSOFT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_BAIDU]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_BAIDU,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_TENCENT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_TENCENT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_VOLCENGINE]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_VOLCENGINE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPL]:{url:"https://api-free.deepl.com/v2/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPL,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLFREE]:{fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLFREE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLX]:{url:"http://localhost:1188/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLX,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_NIUTRANS]:{url:"https://api.niutrans.com/NiuTransServer/translation",key:"",dictNo:"",memoryNo:"",fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_NIUTRANS,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_OPENAI]:defaultOpenaiApi,[OPT_TRANS_OPENAI_2]:defaultOpenaiApi,[OPT_TRANS_OPENAI_3]:defaultOpenaiApi,[OPT_TRANS_GEMINI]:{url:"https://generativelanguage.googleapis.com/v1/models/".concat(INPUT_PLACE_MODEL,":generateContent?key=").concat(INPUT_PLACE_KEY),key:"",model:"gemini-2.5-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:2048,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_GEMINI_2]:{url:"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions",key:"",model:"gemini-2.0-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,reasoningEffort:"low",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLAUDE]:{url:"https://api.anthropic.com/v1/messages",key:"",model:"claude-3-haiku-20240307",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:1024,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLAUDE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLOUDFLAREAI]:{url:"https://api.cloudflare.com/client/v4/accounts/{{ACCOUNT_ID}}/ai/run/@cf/meta/m2m100-1.2b",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLOUDFLAREAI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_OLLAMA]:defaultOllamaApi,[OPT_TRANS_OLLAMA_2]:defaultOllamaApi,[OPT_TRANS_OLLAMA_3]:defaultOllamaApi,[OPT_TRANS_CUSTOMIZE]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_2]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_3]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_4]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_5]:defaultCustomApi};// 默认快捷键
},[OPT_TRANS_GOOGLE_2]:{url:URL_GOOGLE_TRAN2,key:DEFAULT_GOOGLE_API_KEY,fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_GOOGLE_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_MICROSOFT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_MICROSOFT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_BAIDU]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_BAIDU,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_TENCENT]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_TENCENT,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_VOLCENGINE]:{fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_VOLCENGINE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPL]:{url:"https://api-free.deepl.com/v2/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPL,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLFREE]:{fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLFREE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_DEEPLX]:{url:"http://localhost:1188/translate",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_DEEPLX,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_NIUTRANS]:{url:"https://api.niutrans.com/NiuTransServer/translation",key:"",dictNo:"",memoryNo:"",fetchLimit:DEFAULT_FETCH_LIMIT,fetchInterval:DEFAULT_FETCH_INTERVAL,apiName:OPT_TRANS_NIUTRANS,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT},[OPT_TRANS_OPENAI]:defaultOpenaiApi,[OPT_TRANS_OPENAI_2]:defaultOpenaiApi,[OPT_TRANS_OPENAI_3]:defaultOpenaiApi,[OPT_TRANS_GEMINI]:{url:"https://generativelanguage.googleapis.com/v1/models/".concat(INPUT_PLACE_MODEL,":generateContent?key=").concat(INPUT_PLACE_KEY),key:"",model:"gemini-2.5-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:2048,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_GEMINI_2]:{url:"https://generativelanguage.googleapis.com/v1beta/openai/chat/completions",key:"",model:"gemini-2.0-flash",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:2048,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_GEMINI_2,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLAUDE]:{url:"https://api.anthropic.com/v1/messages",key:"",model:"claude-3-haiku-20240307",systemPrompt:"You are a professional, authentic machine translation engine.",userPrompt:"Translate the following source text from ".concat(INPUT_PLACE_FROM," to ").concat(INPUT_PLACE_TO,". Output translation directly without any additional text.\n\nSource Text: ").concat(INPUT_PLACE_TEXT,"\n\nTranslated Text:"),temperature:0,maxTokens:1024,fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLAUDE,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_CLOUDFLAREAI]:{url:"https://api.cloudflare.com/client/v4/accounts/{{ACCOUNT_ID}}/ai/run/@cf/meta/m2m100-1.2b",key:"",fetchLimit:1,fetchInterval:500,apiName:OPT_TRANS_CLOUDFLAREAI,isDisabled:false,httpTimeout:DEFAULT_HTTP_TIMEOUT*2},[OPT_TRANS_OLLAMA]:defaultOllamaApi,[OPT_TRANS_OLLAMA_2]:defaultOllamaApi,[OPT_TRANS_OLLAMA_3]:defaultOllamaApi,[OPT_TRANS_CUSTOMIZE]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_2]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_3]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_4]:defaultCustomApi,[OPT_TRANS_CUSTOMIZE_5]:defaultCustomApi};// 默认快捷键
const OPT_SHORTCUT_TRANSLATE="toggleTranslate";const OPT_SHORTCUT_STYLE="toggleStyle";const OPT_SHORTCUT_POPUP="togglePopup";const OPT_SHORTCUT_SETTING="openSetting";const DEFAULT_SHORTCUTS={[OPT_SHORTCUT_TRANSLATE]:["AltLeft","KeyQ"],[OPT_SHORTCUT_STYLE]:["AltLeft","KeyC"],[OPT_SHORTCUT_POPUP]:["AltLeft","KeyK"],[OPT_SHORTCUT_SETTING]:["AltLeft","KeyO"]};const TRANS_MIN_LENGTH=5;// 最短翻译长度
const TRANS_MAX_LENGTH=5000;// 最长翻译长度
const TRANS_NEWLINE_LENGTH=20;// 换行字符数
@@ -34861,7 +34861,7 @@ subRulesSyncAt:0,// 订阅规则同步时间
dataCaches:{}// 缓存同步时间
};
;// CONCATENATED MODULE: ./src/index.js
function App(){var _I18N$about_md;const[lang,setLang]=(0,react.useState)("zh");const[data,loading,error]=useFetch("".concat(URL_RAW_PREFIX,"/").concat(I18N===null||I18N===void 0?void 0:(_I18N$about_md=I18N["about_md"])===null||_I18N$about_md===void 0?void 0:_I18N$about_md[lang]));return/*#__PURE__*/(0,jsx_runtime.jsxs)(Paper_Paper,{sx:{padding:2,margin:2},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Stack_Stack,{spacing:2,direction:"row",justifyContent:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{variant:"text",onClick:()=>{setLang(pre=>pre==="zh"?"en":"zh");},children:lang==="zh"?"ENGLISH":"中文"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("1.9.0")})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/options.html",children:"Open Options Page"})]}),loading?/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown,{children:error?error.message:data})]});}const src_root=client.createRoot(document.getElementById("root"));src_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(App,{})}));
function App(){var _I18N$about_md;const[lang,setLang]=(0,react.useState)("zh");const[data,loading,error]=useFetch("".concat(URL_RAW_PREFIX,"/").concat(I18N===null||I18N===void 0?void 0:(_I18N$about_md=I18N["about_md"])===null||_I18N$about_md===void 0?void 0:_I18N$about_md[lang]));return/*#__PURE__*/(0,jsx_runtime.jsxs)(Paper_Paper,{sx:{padding:2,margin:2},children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Stack_Stack,{spacing:2,direction:"row",justifyContent:"flex-end",children:/*#__PURE__*/(0,jsx_runtime.jsx)(Button_Button,{variant:"text",onClick:()=>{setLang(pre=>pre==="zh"?"en":"zh");},children:lang==="zh"?"ENGLISH":"中文"})}),/*#__PURE__*/(0,jsx_runtime.jsx)(Divider_Divider,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://github.com/fishjar/kiss-translator",children:"KISS Translator v".concat("1.9.1")})}),/*#__PURE__*/(0,jsx_runtime.jsxs)(Stack_Stack,{spacing:2,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator.user.js",children:"Install/Update Userscript for Tampermonkey/Violentmonkey"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/kiss-translator-ios-safari.user.js",children:"Install/Update Userscript for iOS Safari"}),/*#__PURE__*/(0,jsx_runtime.jsx)(Link_Link,{href:"https://fishjar.github.io/kiss-translator/options.html",children:"Open Options Page"})]}),loading?/*#__PURE__*/(0,jsx_runtime.jsx)("center",{children:/*#__PURE__*/(0,jsx_runtime.jsx)(CircularProgress_CircularProgress,{})}):/*#__PURE__*/(0,jsx_runtime.jsx)(ReactMarkdown,{children:error?error.message:data})]});}const src_root=client.createRoot(document.getElementById("root"));src_root.render(/*#__PURE__*/(0,jsx_runtime.jsx)(react.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(App,{})}));
})();
/******/ })()

View File

@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_app_name__",
"description": "__MSG_app_description__",
"version": "1.9.0",
"version": "1.9.1",
"default_locale": "en",
"author": "Gabe<yugang2002@gmail.com>",
"homepage_url": "https://github.com/fishjar/kiss-translator",

View File

@@ -2,7 +2,7 @@
"manifest_version": 3,
"name": "__MSG_app_name__",
"description": "__MSG_app_description__",
"version": "1.9.0",
"version": "1.9.1",
"default_locale": "en",
"author": "Gabe<yugang2002@gmail.com>",
"homepage_url": "https://github.com/fishjar/kiss-translator",

View File

@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "__MSG_app_name__",
"description": "__MSG_app_description__",
"version": "1.9.0",
"version": "1.9.1",
"default_locale": "en",
"author": "Gabe<yugang2002@gmail.com>",
"homepage_url": "https://github.com/fishjar/kiss-translator",

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
1.9.0
1.9.1