Change Text Alignment for Translated Text

Change text alignment to right (like Microsoft Edge when translating to Arabic)

  1. // ==UserScript==
  2. // @name Change Text Alignment for Translated Text
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Change text alignment to right (like Microsoft Edge when translating to Arabic)
  6. // @author You
  7. // @match *://*/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to change text alignment
  16. function changeTextAlignment() {
  17. const body = document.querySelector('body');
  18. if (body) {
  19. body.style.direction = 'rtl';
  20. body.style.textAlign = 'right';
  21. }
  22. }
  23.  
  24. // Call the function
  25. changeTextAlignment();
  26. })();