Translate Web Page

Translate Web Page.

  1. // ==UserScript==
  2. // @name Translate Web Page
  3. // @description Translate Web Page.
  4. // @version 0.1
  5. // @author to
  6. // @namespace https://github.com/to
  7. // @license MIT
  8. // @match *://*/*
  9. //
  10. // @grant GM_registerMenuCommand
  11. // @grant GM_openInTab
  12. //
  13. // @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
  14. // ==/UserScript==
  15.  
  16. const TO_LANG = 'ja';
  17. const FROM_LANG = 'auto';
  18.  
  19. GM_registerMenuCommand('by Google', () => {
  20. GM_openInTab(
  21. location.href.replace(
  22. location.host,
  23. location.host.replaceAll('.', '-') + '.translate.goog') +
  24. `?_x_tr_sl=${FROM_LANG}&_x_tr_tl=${TO_LANG}&_x_tr_hl=${TO_LANG}`);
  25. });