ChatGPT Character Counter Limit (CCCL)

Adds a character counter to the input field with a limit of 32732 characters. (ChatGPT has a limit of 32732 characters.)

目前為 2024-08-29 提交的版本,檢視 最新版本

// ==UserScript==
// @name         ChatGPT Character Counter Limit (CCCL)
// @namespace    http://tampermonkey.net/
// @version      1.3
// @description  Adds a character counter to the input field with a limit of 32732 characters. (ChatGPT has a limit of 32732 characters.)
// @author       Emree.el on instagram 
// @match        https://chatgpt.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to add character counter and handle its behavior
    function addCharacterCounter() {
        let textarea = document.querySelector('#prompt-textarea');

        if (textarea) {
            let charCounter = document.createElement('div');
            charCounter.style.fontSize = '14px';
            charCounter.style.fontWeight = 'bold';
            charCounter.style.marginTop = '5px';
            charCounter.style.color = 'white';
            charCounter.style.textShadow = '0px 0px 5px white'; // Default text shadow

            charCounter.textContent = '0/32732';

            textarea.parentElement.appendChild(charCounter);

            function updateCounter() {
                let charCount = textarea.value.length;
                charCounter.textContent = `${charCount}/32732`;

                if (charCount > 32732) {
                    charCounter.style.color = 'white';
                    charCounter.style.textShadow = '0px 0px 8px red';
                } else if (charCount > 0) {
                    charCounter.style.color = 'white';
                    charCounter.style.textShadow = '0px 0px 8px green';
                } else {
                    charCounter.style.color = 'white';
                    charCounter.style.textShadow = '0px 0px 5px white';
                }
            }

            textarea.addEventListener('input', function() {
                updateCounter();
            });

            let sendButton = document.querySelector('[aria-label="Send prompt"]');
            sendButton.addEventListener('click', function() {
                setTimeout(function() {
                    textarea.value = ''; // Clear the textarea
                    charCounter.textContent = '0/32732'; // Reset the counter
                    charCounter.style.color = 'white';
                    charCounter.style.textShadow = '0px 0px 5px white'; // Reset color and glow
                }, 100); // Slight delay to ensure message is sent before resetting
            });
        } else {
            // Retry if the textarea isn't loaded yet
            setTimeout(addCharacterCounter, 500);
        }
    }

    // Run the function after the page loads
    window.addEventListener('load', addCharacterCounter);
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址