{"url_pattern":"^https?://dict\\.youdao\\.com(/.*)?$","site_name":"youdao","allowed_domains":["dict.youdao.com"],"tools":[{"name":"youdao_translate","description":"有道翻译/词典查询","inputSchema":{"type":"object","properties":{"query":{"type":"string","description":"Word or sentence to translate (English or Chinese)"}},"required":["query"]},"handler":"(params) => {\n  const run = async function(args) {\n\n      if (!args.query) return {error: 'Missing argument: query'};\n      var q = args.query.trim();\n\n      var resp = await fetch('https://dict.youdao.com/jsonapi_s?doctype=json&jsonversion=4&q=' + encodeURIComponent(q), {credentials: 'include'});\n      if (!resp.ok) return {error: 'HTTP ' + resp.status};\n      var d = await resp.json();\n\n      var result = {query: q, language: (d.meta && d.meta.guessLanguage) || null};\n\n      // --- Sentence translation (fanyi) ---\n      if (d.fanyi && d.fanyi.tran) {\n        result.translation = {\n          type: d.fanyi.type || null,\n          result: d.fanyi.tran\n        };\n      }\n\n      // --- Phonetic (simple) ---\n      if (d.simple && d.simple.word && d.simple.word[0]) {\n        var w = d.simple.word[0];\n        result.phonetic = {};\n        if (w.usphone) result.phonetic.us = w.usphone;\n        if (w.ukphone) result.phonetic.uk = w.ukphone;\n        if (w.phone) result.phonetic.pinyin = w.phone;\n      }\n\n      // --- English-Chinese dict (ec) ---\n      if (d.ec && d.ec.word && d.ec.word.trs) {\n        result.definitions = d.ec.word.trs.map(function(t) {\n          return {pos: t.pos || '', meaning: t.tran || ''};\n        });\n        // Exam types\n        if (d.ec.exam_type) result.examTypes = d.ec.exam_type;\n        // Word forms\n        if (d.ec.word.wfs) {\n          result.wordForms = d.ec.word.wfs.map(function(f) {\n            return {type: f.wf.name, value: f.wf.value};\n          });\n        }\n      }\n\n      // --- Chinese-English dict (ce) ---\n      if (d.ce && d.ce.word && d.ce.word.trs) {\n        result.definitions = d.ce.word.trs.map(function(t) {\n          return {word: t['#text'] || '', meaning: t['#tran'] || ''};\n        });\n      }\n\n      // --- Web translations ---\n      if (d.web_trans && d.web_trans['web-translation']) {\n        var wt = d.web_trans['web-translation'];\n        result.webTranslations = wt.slice(0, 5).map(function(item) {\n          return {\n            key: item.key,\n            values: (item.trans || []).map(function(t) { return t.value; }).filter(Boolean)\n          };\n        });\n      }\n\n      // --- Phrases ---\n      if (d.phrs && d.phrs.phrs) {\n        result.phrases = d.phrs.phrs.slice(0, 6).map(function(p) {\n          return {phrase: p.headword, meaning: p.translation};\n        });\n      }\n\n      // --- Bilingual example sentences ---\n      if (d.blng_sents_part && d.blng_sents_part['sentence-pair']) {\n        result.examples = d.blng_sents_part['sentence-pair'].slice(0, 5).map(function(s) {\n          return {\n            en: (s.sentence || '').replace(/<[^>]+>/g, ''),\n            zh: (s['sentence-translation'] || '').replace(/<[^>]+>/g, '')\n          };\n        });\n      }\n\n      // --- Synonyms ---\n      if (d.syno && d.syno.synos) {\n        result.synonyms = d.syno.synos.slice(0, 4).map(function(s) {\n          return {pos: s.pos || '', words: (s.ws || []).map(function(w) { return w.w; })};\n        });\n      }\n\n      // --- Etymology ---\n      if (d.etym && d.etym.etyms && d.etym.etyms.zh) {\n        result.etymology = d.etym.etyms.zh.map(function(e) { return e.value || e; }).join(' ');\n      }\n\n      return result;\n  };\n  return run(params || {});\n}"}]}