Klik equation ChatGPT untuk otomatis menyalin LaTeX
This UserScript adds a dedicated copy button next to mathematical equations displayed in ChatGPT.
It is designed for users who frequently copy equations from ChatGPT into
Microsoft Word, Overleaf, LaTeX editors, Markdown documents, academic reports, or other applications that support LaTeX notation.
$...$.$...$, $$...$$, and \[...\].\\.
An equation such as:
\frac{x+1}{x-1}
will be copied as:
$\frac{x+1}{x-1}$
The script also converts compact fraction notation such as:
\frac12
into:
\frac{1}{2}
This format is generally safer when pasting equations into Microsoft Word.
Alt + =, or use Insert → Equation.
This workflow is especially useful for academic writing, reports, assignments, theses, and documents containing many mathematical expressions.
https://chatgpt.com/*
https://chat.openai.com/*
The script detects mathematical expressions using the following selectors:
[data-math-source], .katex
It attempts to retrieve the original LaTeX source from the
data-math-source attribute.
If that source is unavailable, it reads the KaTeX annotation:
<annotation encoding="application/x-tex">
A MutationObserver monitors newly generated page content, allowing the script to detect equations that appear while ChatGPT is generating a response.
No page refresh is required.
The copy control uses an SVG icon instead of visible text.
This avoids adding labels such as “LaTeX” to the selected text when a user highlights and copies an entire ChatGPT response.
The button is also configured with:
user-select: none;
-webkit-user-select: none;
This makes the button itself less likely to interfere with normal text selection.
This script does not send data to external servers and does not use third-party APIs.
The only special UserScript permission used is:
@grant GM_setClipboard
This permission is required solely for copying the formatted LaTeX equation to the clipboard.
ChatGPT's page structure may change over time.
If OpenAI changes the way mathematical equations are rendered, the script may require updates.
If you find an equation that is not detected correctly or a LaTeX expression that is copied incorrectly,
please report the issue through the Greasy Fork feedback section and include an example equation whenever possible.
MutationObserver.