Greasy Fork

Greasy Fork is available in English.

chatGPT辅助脚本 长文本分割

自动将英文文本分割为chatGPT可以承受住的输入量,省去人工分割的步骤。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        chatGPT辅助脚本 长文本分割
// @namespace   https://github.com/Huoyuuu
// @include     https://chat.openai.com/*
// @description 自动将英文文本分割为chatGPT可以承受住的输入量,省去人工分割的步骤。
// @author      Huoyuuu
// @version     1.1
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require     https://code.jquery.com/ui/1.12.1/jquery-ui.min.js
// @grant       none
// @license     MIT
// ==/UserScript==

$(document).ready(function() {
    // Create textbox and button
    var textbox = $('<textarea>').css({
        'width': '100%',
        'resize': 'both',
    });
    var button = $('<button>Divide</button>').css({
        'width': '100%',
        'height': '2%',
    });
    var container = $('<div>').css({
        'position': 'absolute',
        'right': '20%',
        'top': '50%',
        'transform': 'translate(50%, -50%)',
        'text-align': 'center',
        'z-index': '9999',
    });
    var toggleBtn = $('<button>Toggle</button>').css({
        'width': '100%',
        'height': '2%',
    });

    //$(container).hide(); // hide the container by default

    toggleBtn.click(function() {
        $(container).toggle();
    });
    container.append(toggleBtn);
    toggleBtn.css({
        'display': 'inline-block',
        'margin': '0 auto'
    });

    $(container).draggable({
        containment: "parent"
    });
    textbox.css({
        'display': 'inline-block',
        'margin': '0 auto'
    });
    button.css({
        'display': 'inline-block',
        'margin': '0 auto'
    });
    container.append(textbox);
    container.append(button);
    // Append textbox and button to the body
    $('body').append(container);

    // Add click event to button
    button.click(function() {
        // Get the text from the textbox
        var text = textbox.val();
        // Split the text into paragraphs
        var paragraphs = text.split("\n");
        var ret = "Express it in succinct sentences:";
        var curlen = 0;
        // Loop through each paragraph
        for (var i = 0; i < paragraphs.length; i++) {
            var words = paragraphs[i].replaceAll("\n", " ").split(" ");
            var len = words.length;
            if (len <= 2) {
                continue;
            }

            curlen += len;
            if (curlen > 1400) {
                curlen = 0;
                ret += "\n\n\nExpress it in succinct sentences:";
                continue;
            }
            ret += paragraphs[i];
        }
        // Update the text in the textbox
        textbox.val(ret);
    });
});