DeepL Free API (No TOKEN required)
Go to file
Vincent Young 10f33401e7
fix(translate): align oneshot request bytes with the real extension
After capturing the exact bytes the Chrome extension's service-worker
fetch() emits (via an offline echo server pointed at deeplx in place of
oneshot-free.www.deepl.com) and diffing them against what we were
sending, several distinguishable signals remained. Close them all.

Headers
-------
- Origin: chrome-extension://cofdbpoegempjloogbagkncekinflcnj
  (was https://www.deepl.com — a request from www.deepl.com itself
   never lands on the oneshot endpoint, so that origin is unusual.
   The extension ID is the canonical sender.)
- Sec-Fetch-Site: cross-site
  (was same-site — wrong; chrome-extension -> www.deepl.com IS cross-site)
- Drop Referer entirely (extension SW fetch sends none)
- Drop Pragma / Cache-Control / Upgrade-Insecure-Requests / Sec-Fetch-User
  (req.ImpersonateChrome() sets these for top-level navigation; a
   fetch() never sends them — leaving them in is a strong nav-vs-XHR tell)
- Accept-Encoding: gzip, deflate, br
  (was just gzip, Go stdlib default — Chrome 120's fetch() sends all
   three; zstd only landed as a default in Chrome 123+ so leave it off)

Body
----
- Add usage_type: "Translate" and the full app_information object
  (os/os_version/app_version/app_build/instance_id) so the JSON the
  server sees is structurally identical to what background.js IN()
  assembles. Field order in oneshotRequest matches the extension's
  object-literal order so encoding/json produces byte-identical output.
- instance_id is a v4 UUID generated once at process start and reused,
  mirroring the extension's chrome.storage-pinned ID rather than
  rotating per-request (rotation would be a far stronger signal).
- All version strings (TLS handshake, User-Agent, sec-ch-ua,
  app_information.os_version) are pinned to Chrome 120 so they tell
  one consistent story.

Transport
---------
- SetBodyBytes instead of bytes.NewReader so Content-Length is set
  (an io.Reader body forces Transfer-Encoding: chunked, which a
   fetch() with JSON.stringify body never emits)
- Once we set Accept-Encoding manually, the Go stdlib disables its
  transparent decompression and req hands us raw compressed bytes.
  Handle gzip / deflate / br by hand from Content-Encoding.
- DisableAutoReadResponse so we own the body stream end-to-end.

The Chrome 120 TLS ClientHello, HTTP/2 SETTINGS frame, pseudo-header
order and sec-ch-ua claim continue to come from ImpersonateChrome()
unchanged.

Verified end-to-end:
- Outbound bytes (against a local echo server) diff-match the
  extension's observed profile on every header and on body JSON order.
- Live oneshot-free.www.deepl.com calls: 4 language pairs OK,
  /v2/translate official-API compat OK, 10x burst 10/10 200.
2026-05-22 11:53:14 +08:00
.github chore: bump Go version to 1.24.2 in Dockerfile, go.mod, and CI workflows 2025-04-08 14:27:01 -04:00
img docs: add img 2024-03-02 02:47:18 -05:00
service refactor: make service exportable (#183) 2025-04-08 13:53:20 -04:00
translate fix(translate): align oneshot request bytes with the real extension 2026-05-22 11:53:14 +08:00
.cross_compile.sh ci: fix compile error 2024-03-20 16:52:54 -04:00
.gitignore chore: add gitignore 2023-07-01 21:31:38 +08:00
compose.yaml Update compose.yaml 2024-12-22 14:18:30 -05:00
deeplx.service Update deeplx.service 2023-02-18 20:55:20 +08:00
Dockerfile Update Dockerfile to use Go 1.25 base image (#215) 2026-03-18 03:47:26 -07:00
go.mod fix(translate): align oneshot request bytes with the real extension 2026-05-22 11:53:14 +08:00
go.sum feat(translate): migrate to oneshot endpoint to bypass www2 anti-bot 2026-05-22 11:34:55 +08:00
install.sh Update install.sh 2023-02-18 20:57:58 +08:00
LICENSE Create LICENSE 2022-10-20 02:12:18 +08:00
main.go refactor: make service exportable (#183) 2025-04-08 13:53:20 -04:00
me.missuo.deeplx.plist Update README.md 2022-10-20 02:11:14 +08:00
README.md docs: remove icon 2024-11-30 19:56:38 -05:00
uninstall.sh feat(uninstall): Add DeepLX uninstallation script (#203) 2025-08-26 20:34:10 +08:00

GitHub Workflow Go Version Go Report GitHub License Docker Pulls Releases

How to use

!TIP]

Learn more about [📘 Using DeepLX](https://deeplx.owo.network) by checking it out.

Discussion Group

Telegram Group

Acknowledgements

Contributors

Activity

Alt

License

FOSSA Status