Kill EM Dashes on ChatGPT

Replaces em dashes with a comma on ChatGPT

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Kill EM Dashes on ChatGPT
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Replaces em dashes with a comma on ChatGPT
// @author       livejamie
// @license      MIT
// @match        https://chatgpt.com/*
// @grant        none
// ==/UserScript==

/*
MIT License

Copyright (c) 2025 livejamie
*/

(function() {
    'use strict';

    function replaceDashes(node) {
        if (node.nodeType === Node.TEXT_NODE) {
            node.textContent = node.textContent.replace(/\s*[—–]\s*/g, ', ');
        } else if (node.nodeType === Node.ELEMENT_NODE) {
            node.childNodes.forEach(replaceDashes);
        }
    }

    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            mutation.addedNodes.forEach(replaceDashes);
        });
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true
    });

    replaceDashes(document.body);
})();