Skip to content

fix: RTL support broken on chatgpt.com — responses in RTL languages render LTR - #36

Merged
kalagar merged 4 commits into
masterfrom
copilot/fix-rtl-support-chatgpt
Jun 20, 2026
Merged

fix: RTL support broken on chatgpt.com — responses in RTL languages render LTR#36
kalagar merged 4 commits into
masterfrom
copilot/fix-rtl-support-chatgpt

Conversation

Copilot AI commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

ChatGPT doesn't annotate its response containers with lang or dir attributes, so GENERAL_RTL_CSS ([lang|="ar"], [dir="rtl"], etc.) never matched any element — enabling RTL for chatgpt.com had no effect.

Changes

  • src/lib/css.js — adds CHATGPT_RTL_CSS targeting ChatGPT's actual response DOM: [data-message-author-role="assistant"] .markdown and its block-level descendants (p, li, h1h6, blockquote, pre, td, th) with unicode-bidi: plaintext; text-align: start. Same bidi-algorithm approach used for YouTube — no JS text scanning needed.

  • src/lib/config.js — adds CHATGPT_HOSTNAMES set (chatgpt.com, www.chatgpt.com) to identify when the site-specific CSS path applies.

  • src/content.jsrender() now selects CSS in three tiers: YouTube → RTL_CSS, ChatGPT → CHATGPT_RTL_CSS, everything else → GENERAL_RTL_CSS.

if (DEFAULT_RTL_HOSTNAMES.has(hostname)) {
  css = RTL_CSS;
} else if (CHATGPT_HOSTNAMES.has(hostname)) {
  css = CHATGPT_RTL_CSS;
} else {
  css = GENERAL_RTL_CSS;
}

The RTL toggle for chatgpt.com already exists in the popup and Options page — users just need to enable it.

Test plan

  • Loaded extension as unpacked in Chrome
  • Tested on at least 2–3 different sites
  • Icon fonts (Material Icons / Font Awesome) still render correctly
  • No console errors on affected pages

Copilot AI changed the title [WIP] Fix RTL support for responses in RTL languages fix: RTL support broken on chatgpt.com — responses in RTL languages render LTR Jun 20, 2026
Copilot AI requested a review from kalagar June 20, 2026 18:54
@kalagar
kalagar requested a review from Copilot June 20, 2026 18:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes RTL rendering on chatgpt.com by adding a ChatGPT-specific CSS selector set and selecting it in the content script when the hostname matches chatgpt.com, since ChatGPT responses typically lack lang/dir attributes that the generic RTL selector relies on.

Changes:

  • Add CHATGPT_RTL_CSS to target ChatGPT assistant message markdown blocks and apply unicode-bidi: plaintext + text-align: start.
  • Add CHATGPT_HOSTNAMES and update the content script to choose RTL CSS in three tiers (YouTube / ChatGPT / generic).
  • Update the bundled content.js output and document the fix in CHANGELOG.md.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/lib/css.js Introduces CHATGPT_RTL_CSS targeting ChatGPT assistant markdown output.
src/lib/config.js Adds CHATGPT_HOSTNAMES for site-specific RTL handling.
src/content.js Selects the appropriate RTL CSS (YouTube vs ChatGPT vs generic) during render.
content.js Updates the built/bundled content script to include the new CSS/hostname logic.
CHANGELOG.md Adds an Unreleased changelog entry documenting the ChatGPT RTL fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CHANGELOG.md Outdated
@kalagar
kalagar marked this pull request as ready for review June 20, 2026 18:57
Copilot AI requested a review from kalagar June 20, 2026 18:58
@kalagar
kalagar merged commit 65f938f into master Jun 20, 2026
2 checks passed
@kalagar
kalagar deleted the copilot/fix-rtl-support-chatgpt branch June 20, 2026 19:01
kalagar added a commit that referenced this pull request Jun 20, 2026
🤖 I have created a release *beep* *boop*
---


## [1.4.1](v1.4.0...v1.4.1)
(2026-06-20)


### Bug Fixes

* RTL support broken on chatgpt.com — responses in RTL languages render
LTR ([#36](#36))
([65f938f](65f938f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants