├── .commitlintrc.cjs ├── .github └── workflows │ └── release.yaml ├── .gitignore ├── .husky └── commit-msg ├── .release-it.cjs ├── CHANGELOG.md ├── README.md ├── appcast.json ├── image ├── en-to-zh.png └── zh-to-en.png ├── package.json ├── scripts └── build.cjs ├── server ├── app.js └── package.json └── src ├── config.js ├── icon.png ├── info.json └── main.js /.commitlintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ["@commitlint/config-conventional"], 3 | }; 4 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release 2 | on: 3 | push: 4 | tags: 5 | - "v*" 6 | 7 | jobs: 8 | build: 9 | runs-on: macos-latest 10 | steps: 11 | - uses: actions/checkout@v2 12 | with: 13 | fetch-depth: 0 14 | token: ${{ secrets.BOBPLUGIN_TOKEN }} 15 | 16 | - uses: actions/setup-node@v2-beta 17 | with: 18 | node-version: "14" 19 | 20 | - name: Install Dependencies And Build 21 | run: | 22 | yarn install 23 | yarn build 24 | 25 | - name: Commit files 26 | run: | 27 | git config --global user.name 'ayang' 28 | git config --global user.email '473033518@qq.com' 29 | git commit -am "chore: update version" 30 | - name: Push changes 31 | uses: ad-m/github-push-action@master 32 | with: 33 | github_token: ${{ secrets.BOBPLUGIN_TOKEN }} 34 | 35 | - uses: ncipollo/release-action@v1 36 | with: 37 | artifacts: "release/*.bobplugin" 38 | token: ${{ secrets.BOBPLUGIN_TOKEN }} 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | package-lock.json* 10 | yarn.lock* 11 | pnpm-lock.yaml* 12 | 13 | node_modules 14 | dist 15 | dist-ssr 16 | *.local 17 | *.bobplugin 18 | release 19 | 20 | # Editor directories and files 21 | .vscode/* 22 | !.vscode/extensions.json 23 | .idea 24 | .DS_Store 25 | *.suo 26 | *.ntvs* 27 | *.njsproj 28 | *.sln 29 | *.sw? 30 | -------------------------------------------------------------------------------- /.husky/commit-msg: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx --no-install commitlint -e 5 | -------------------------------------------------------------------------------- /.release-it.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | git: { 3 | commitMessage: "v${version}", 4 | tagName: "v${version}", 5 | }, 6 | github: { 7 | release: false, 8 | releaseName: "v${version}", 9 | }, 10 | npm: { 11 | publish: false, 12 | }, 13 | plugins: { 14 | "@release-it/conventional-changelog": { 15 | preset: "angular", 16 | infile: "CHANGELOG.md", 17 | ignoreRecommendedBump: true, 18 | }, 19 | }, 20 | }; 21 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## [0.0.5](https://github.com/ayangweb/bob-plugin-free-bing-translate/compare/v0.0.4...v0.0.5) (2024-04-23) 4 | 5 | 6 | ### Performance Improvements 7 | 8 | * optimized code ([eb341b4](https://github.com/ayangweb/bob-plugin-free-bing-translate/commit/eb341b4103fca19fada914ef2bf33f3ad000d7be)) 9 | 10 | ## [0.0.4](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/compare/v0.0.3...v0.0.4) (2023-08-27) 11 | 12 | 13 | ### Bug Fixes 14 | 15 | * fix unknown bug ([ab0cdf7](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/commit/ab0cdf7ec247a48730f730941b2ba71809efd55c)) 16 | 17 | 18 | ### Features 19 | 20 | * add a calculator plug-in to a document ([11a09c5](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/commit/11a09c59db5ef97d36190872cbe6960695dc5ea9)) 21 | * document added calf translate ([18633de](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/commit/18633de435c189eea205fbad7119e3508ea72c1f)) 22 | * update docs ([c58cc21](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/commit/c58cc21cb20abd884d56068c69f9187a44af1f7f)) 23 | 24 | 25 | ### Performance Improvements 26 | 27 | * optimized build of packages ([adcb5b8](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/commit/adcb5b8938167d7ae44032a2b843c7e5191263cd)) 28 | 29 | ## [0.0.3](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/compare/v0.0.2...v0.0.3) (2023-03-03) 30 | 31 | 32 | ### Features 33 | 34 | * update docs ([f41cfea](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/commit/f41cfea576af89c981a8da634889b311fd4e26c5)) 35 | * update docs ([9ea3345](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/commit/9ea3345bfb4ff5d8a72c87483fdb4da57c0e534f)) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 必应翻译 2 | 3 | ## 无需秘钥,可以直接在 bob 中进行工作,如果有一天它不工作了,请联系我进行修复! 4 | 5 | > src 文件夹主要为 bob 用户开发,bob 是一款 macOS 上的翻译软件,官网地址:[bob](https://bobtranslate.com/) 6 | > 7 | > 插件下载地址:[bob-plugin-free-bing-translate-v0.0.5.bobplugin](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/releases/download/v0.0.5/bob-plugin-free-bing-translate.bobplugin) 8 | 9 | > server 文件夹是 node.js 服务器,可以自行改造后在任意场景下使用! 10 | 11 | ### bob 插件大合集: 12 | 13 | > [chatGPT 插件(免秘钥,免翻)](https://github.com/bilibili-ayang/bob-plugin-free-chatgpt) 14 | 15 | > [百度翻译插件(免秘钥)](https://github.com/bilibili-ayang/bob-plugin-free-baidu-translate) 16 | 17 | > [小牛翻译插件(免秘钥)](https://github.com/bilibili-ayang/bob-plugin-free-calf-translate) 18 | 19 | > [阿里翻译插件(免秘钥)](https://github.com/bilibili-ayang/bob-plugin-free-ali-translate) 20 | 21 | > [搜狗翻译插件(免秘钥)](https://github.com/bilibili-ayang/bob-plugin-free-sougou-translate) 22 | 23 | > [爱词霸翻译插件(免秘钥)](https://github.com/bilibili-ayang/bob-plugin-free-iciba-translate) 24 | 25 | > [计算器插件](https://github.com/bilibili-ayang/bob-plugin-calculator) 26 | 27 | > [必应翻译插件(免秘钥)](https://github.com/bilibili-ayang/bob-plugin-free-bing-translate) 28 | 29 | ### 使用截图如下: 30 | 31 | zh-to-en 32 | en-to-zh 33 | -------------------------------------------------------------------------------- /appcast.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": "com.bob-plugin-free-bing-translate", 3 | "versions": [ 4 | { 5 | "version": "0.0.5", 6 | "desc": "https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/blob/master/CHANGELOG.md", 7 | "sha256": "39947365719f84a46dc06e28fe922351623c0414f0b6fcd62604df48b1aa88cb", 8 | "url": "https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/releases/download/v0.0.5/bob-plugin-free-bing-translate.bobplugin", 9 | "minBobVersion": "0.5.0" 10 | }, 11 | { 12 | "version": "0.0.4", 13 | "desc": "https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/blob/master/CHANGELOG.md", 14 | "sha256": "0b17ec229051302b19989235dba543a7344ac2cd15952e29e6764f004bee3305", 15 | "url": "https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/releases/download/v0.0.4/bob-plugin-free-bing-translate.bobplugin", 16 | "minBobVersion": "0.5.0" 17 | }, 18 | { 19 | "version": "0.0.3", 20 | "desc": "https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/blob/master/CHANGELOG.md", 21 | "sha256": "c962deec98d6d7d93aa42d6d52abadf8a2ab4f3163f52cfa1d2e4bd43b3998a4", 22 | "url": "https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/releases/download/v0.0.3/bob-plugin-free-bing-translate.bobplugin", 23 | "minBobVersion": "0.5.0" 24 | }, 25 | { 26 | "version": "0.0.2", 27 | "desc": "重构了请求接口时的参数传递", 28 | "sha256": "3881ca3b9f76260e281ea937f73e63f378764875a9fae9496ea0af88e3164f38", 29 | "url": "https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/releases/download/v0.0.2/bob-plugin-free-bing-translate.bobplugin", 30 | "minBobVersion": "0.5.0" 31 | }, 32 | { 33 | "version": "0.0.1", 34 | "desc": "初始版本", 35 | "sha256": "9a72b4126b9882f50198fb649a1b1773e72539cc22677472dcbc1fe11135ff21", 36 | "url": "https://github.com/bilibili-ayang/bob-plugin-free-bing-translate/releases/download/v0.0.1/bob-plugin-free-bing-translate.bobplugin", 37 | "minBobVersion": "0.5.0" 38 | } 39 | ] 40 | } 41 | -------------------------------------------------------------------------------- /image/en-to-zh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayangweb/bob-plugin-free-bing-translate/44a106d4dbdaa5abcd8cd22d503cbe89c53519a1/image/en-to-zh.png -------------------------------------------------------------------------------- /image/zh-to-en.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayangweb/bob-plugin-free-bing-translate/44a106d4dbdaa5abcd8cd22d503cbe89c53519a1/image/zh-to-en.png -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bob-plugin-free-bing-translate", 3 | "version": "0.0.5", 4 | "description": "无需秘钥,可以直接在 bob 中进行工作,如果有一天它不工作了,请联系我进行修复!", 5 | "main": "node/app.js", 6 | "scripts": { 7 | "prepare": "husky install", 8 | "build": "node ./scripts/build.cjs", 9 | "release": "release-it" 10 | }, 11 | "keywords": [], 12 | "author": "ayang", 13 | "license": "ISC", 14 | "devDependencies": { 15 | "@commitlint/cli": "^17.4.4", 16 | "@commitlint/config-conventional": "^17.4.4", 17 | "@release-it/conventional-changelog": "^5.1.1", 18 | "adm-zip": "^0.5.10", 19 | "fs-extra": "^11.1.0", 20 | "husky": "^8.0.3", 21 | "release-it": "^15.7.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /scripts/build.cjs: -------------------------------------------------------------------------------- 1 | const fs = require("fs-extra"); 2 | const path = require("path"); 3 | const AdmZip = require("adm-zip"); 4 | const crypto = require("crypto"); 5 | const { name, version } = require("../package.json"); 6 | 7 | const SRC_DIR = path.join(__dirname, "../src"); 8 | 9 | const PLUGIN_DIR = path.join(__dirname, `../release/${name}.bobplugin`); 10 | 11 | const GITHUB_REPOSITORY = "https://github.com/bilibili-ayang/" + name; 12 | 13 | const updateVersion = (dir) => { 14 | dir = path.join(__dirname, dir); 15 | 16 | if (path.extname(dir) === ".md") { 17 | let file = fs.readFileSync(dir, "utf8"); 18 | 19 | file = file.replace(/v\d+\.\d+\.\d+/g, `v${version}`); 20 | 21 | fs.writeFileSync(dir, file); 22 | } else { 23 | let file = fs.readJsonSync(dir); 24 | 25 | if (file?.versions) { 26 | const zip = new AdmZip(); 27 | 28 | const files = fs.readdirSync(SRC_DIR); 29 | 30 | for (const file of files) { 31 | zip.addLocalFile(`${SRC_DIR}/${file}`); 32 | } 33 | 34 | zip.writeZip(PLUGIN_DIR); 35 | 36 | if (file.versions.find((item) => item.version === version)) return; 37 | 38 | const sha256 = crypto 39 | .createHash("sha256") 40 | .update(fs.readFileSync(PLUGIN_DIR)) 41 | .digest("hex") 42 | .toString(); 43 | 44 | file.versions.unshift({ 45 | version, 46 | desc: `${GITHUB_REPOSITORY}/blob/master/CHANGELOG.md`, 47 | sha256, 48 | url: `${GITHUB_REPOSITORY}/releases/download/v${version}/${name}.bobplugin`, 49 | minBobVersion: "0.5.0", 50 | }); 51 | } else { 52 | file.version = version; 53 | } 54 | 55 | fs.outputJSONSync(dir, file, { spaces: 2 }); 56 | } 57 | }; 58 | 59 | // 更新 info.json 60 | updateVersion("../src/info.json"); 61 | 62 | // 更新 README.md 63 | updateVersion("../README.md"); 64 | 65 | // 更新 appcast.json 66 | updateVersion("../appcast.json"); 67 | -------------------------------------------------------------------------------- /server/app.js: -------------------------------------------------------------------------------- 1 | // 引入 koa 框架 2 | const Koa = require("koa2"); 3 | 4 | // 引入处理 post 数据的插件 5 | const bodyParser = require("koa-bodyparser"); 6 | 7 | // 引入 koa 路由 8 | const KoaRouter = require("koa-router"); 9 | 10 | // 引入 axios 11 | const axios = require("axios"); 12 | 13 | // 创建服务器实例 14 | const app = new Koa(); 15 | 16 | // 创建路由实例 17 | const router = new KoaRouter(); 18 | 19 | // 使用bodyParser 20 | app.use(bodyParser()); 21 | 22 | // 使用路由 23 | app.use(router.routes(), router.allowedMethods()); 24 | 25 | // 监听端口 26 | app.listen("5678", () => { 27 | console.log("端口号为 5678 的服务器已经启动!"); 28 | }); 29 | 30 | // 翻译 api 31 | router.post("/translate", async (ctx) => { 32 | // body 传 text(所译文本) 和 to(目标语言) 33 | const { body } = ctx.request; 34 | 35 | const { data } = await axios.get("https://cn.bing.com/translator"); 36 | 37 | const [, IG] = data.match(/IG:"([A-Za-z0-9]+)"/); 38 | const [, IID] = data.match(/data-iid="(.+?)"/); 39 | const [, key, token] = data.match( 40 | /var params_AbusePreventionHelper\s*=\s*\[([0-9]+),\s*"([^"]+)",[^\]]*\];/ 41 | ); 42 | 43 | let bodyParams = { 44 | ...body, 45 | fromLang: "auto-detect", 46 | token, 47 | key, 48 | }; 49 | 50 | const { data: translateResult } = await axios.post( 51 | "https://cn.bing.com/ttranslatev3", 52 | bodyParams, 53 | { 54 | params: { 55 | isVertical: 1, 56 | IG, 57 | IID, 58 | }, 59 | headers: { "content-type": "application/x-www-form-urlencoded" }, 60 | } 61 | ); 62 | 63 | const { statusCode, errorMessage } = translateResult; 64 | 65 | if (statusCode) { 66 | ctx.body = errorMessage; 67 | 68 | return; 69 | } 70 | 71 | ctx.body = translateResult[0].translations[0].text.split("\n"); 72 | }); 73 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bob-plugin-free-bing-translate", 3 | "version": "0.0.1", 4 | "description": "bob-plugin-free-bing-translate", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "nodemon app.js" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "axios": "^1.3.4", 14 | "koa-bodyparser": "^4.3.0", 15 | "koa-router": "^12.0.0", 16 | "koa2": "^2.0.0-alpha.7", 17 | "nodemon": "^2.0.20" 18 | } 19 | } -------------------------------------------------------------------------------- /src/config.js: -------------------------------------------------------------------------------- 1 | const languages = [ 2 | "auto", 3 | "zh-Hant", 4 | "zh-Hans", 5 | "en", 6 | "ko", 7 | "ru", 8 | "ja", 9 | "af", 10 | "bs", 11 | "hr", 12 | "cs", 13 | "da", 14 | "nl", 15 | "et", 16 | "fi", 17 | "fr", 18 | "de", 19 | "hu", 20 | "is", 21 | "it", 22 | "lv", 23 | "lt", 24 | "mi", 25 | "nb", 26 | "pl", 27 | "pt", 28 | "ro", 29 | "sk", 30 | "sl", 31 | "es", 32 | "sv", 33 | "tr", 34 | "vi", 35 | "cy", 36 | "ar", 37 | "as", 38 | "bn", 39 | "bg", 40 | "ca", 41 | "fil", 42 | "fj", 43 | "ga", 44 | "gu", 45 | "el", 46 | "he", 47 | "hi", 48 | "ht", 49 | "id", 50 | "kk", 51 | "kmr", 52 | "kn", 53 | "ku", 54 | "mg", 55 | "ml", 56 | "mr", 57 | "ms", 58 | "mt", 59 | "mww", 60 | "or", 61 | "otq", 62 | "fa", 63 | "pa", 64 | "prs", 65 | "ps", 66 | "pt-PT", 67 | "sm", 68 | "sr-Cyrl", 69 | "sr-Latn", 70 | "sw", 71 | "ta", 72 | "te", 73 | "tlh", 74 | "th", 75 | "to", 76 | "ty", 77 | "uk", 78 | "ur", 79 | "yua", 80 | "yue", 81 | "fr-CA", 82 | "no", 83 | ]; 84 | 85 | exports.languages = languages; 86 | -------------------------------------------------------------------------------- /src/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ayangweb/bob-plugin-free-bing-translate/44a106d4dbdaa5abcd8cd22d503cbe89c53519a1/src/icon.png -------------------------------------------------------------------------------- /src/info.json: -------------------------------------------------------------------------------- 1 | { 2 | "identifier": "com.bob-plugin-free-bing-translate", 3 | "version": "0.0.5", 4 | "category": "translate", 5 | "name": "必应翻译", 6 | "summary": "免token调用必应翻译", 7 | "icon": "icon.png", 8 | "author": "ayang", 9 | "homepage": "https://github.com/bilibili-ayang/bob-plugin-free-bing-translate", 10 | "appcast": "https://raw.githubusercontent.com/bilibili-ayang/bob-plugin-free-bing-translate/master/appcast.json", 11 | "minBobVersion": "0.5.0" 12 | } 13 | -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | var config = require("./config"); 2 | 3 | function supportLanguages() { 4 | return config.languages; 5 | } 6 | 7 | function translate(query, completion) { 8 | (async () => { 9 | try { 10 | const { text, detectFrom: fromLang, detectTo: to } = query; 11 | 12 | const params = await $http.get({ 13 | url: "https://cn.bing.com/translator", 14 | }); 15 | 16 | if (!params?.data) throw new Error(); 17 | 18 | const { data } = params; 19 | 20 | const [, IG] = data.match(/IG:"([A-Za-z0-9]+)"/); 21 | const [, IID] = data.match(/data-iid="(.+?)"/); 22 | const [, key, token] = data.match( 23 | /var params_AbusePreventionHelper\s*=\s*\[([0-9]+),\s*"([^"]+)",[^\]]*\];/ 24 | ); 25 | 26 | const geTranslateResult = async (subdomain = "cn") => { 27 | const result = await $http.post({ 28 | url: `https://${subdomain}.bing.com/ttranslatev3?isVertical=1&IG=${IG}&IID=${IID}`, 29 | body: { 30 | text, 31 | fromLang, 32 | to, 33 | token, 34 | key, 35 | }, 36 | header: { 37 | "content-type": "application/x-www-form-urlencoded", 38 | }, 39 | timeout: 1000 * 60, 40 | }); 41 | 42 | return result; 43 | }; 44 | 45 | let result = await geTranslateResult(); 46 | 47 | if (!result?.data) { 48 | result = await geTranslateResult("www"); 49 | 50 | if (!result?.data) throw new Error(); 51 | } 52 | 53 | const { statusCode, errorMessage } = result.data; 54 | 55 | if (statusCode) throw new Error(errorMessage); 56 | 57 | completion({ 58 | result: { 59 | from: fromLang, 60 | to, 61 | toParagraphs: 62 | result.data[0].translations[0].text.split("\n"), 63 | }, 64 | }); 65 | } catch ({ message }) { 66 | completion({ 67 | error: { 68 | type: "unknown", 69 | message, 70 | }, 71 | }); 72 | } 73 | })(); 74 | } 75 | 76 | exports.supportLanguages = supportLanguages; 77 | exports.translate = translate; 78 | --------------------------------------------------------------------------------