Reddit Fix RTL

Script that fixes Arabic language in Reddit

  1. // ==UserScript==
  2. // @name Reddit Fix RTL
  3. // @version 1.0
  4. // @description Script that fixes Arabic language in Reddit
  5. // @author me
  6. // @match https://*.reddit.com/*
  7. // @namespace https://greasyfork.org/users/1348053
  8. // ==/UserScript==
  9.  
  10. (function () {
  11. function logger(text) {
  12. console.log(`Arabic Reddit: ${text}`);
  13. }
  14.  
  15. function addStyle(styleString) {
  16. const style = document.createElement("style");
  17. style.textContent = styleString;
  18. document.head.append(style);
  19. }
  20.  
  21. function fixDir() {
  22. logger(`fixing dir`);
  23.  
  24. // Fix direction in CSS
  25. addStyle(`
  26. p, h1, a, .title.may-blank,h2 {
  27. unicode-bidi: plaintext;
  28. text-align: start;
  29. }`);
  30. }
  31.  
  32. function fixArabic() {
  33. fixDir();
  34. }
  35.  
  36. fixArabic();
  37. })();