Untitled

mail@pastecode.io avatar
unknown
plain_text
2 months ago
3.8 kB
5
Indexable
Never
// ==UserScript==
// @name         bot Admin mesaji tekrarlar v5
// @namespace    http://tam-adi.com
// @version      0.1
// @description  Mesaj Tekrarlayici
// @author       Astrer
// @match        *://*/*?__cpo=aHR0cHM6Ly9nYXJ0aWMuaW8
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var observer = new MutationObserver(function(mutations) {
        mutations.forEach(function(mutation) {
            if (mutation.type === 'childList') {
                mutation.addedNodes.forEach(function(addedNode) {
                    if (addedNode.classList && addedNode.classList.contains('msg')) {
                        var spanElement = addedNode.querySelector('span');

                        if (spanElement) {
                            var messageText = spanElement.innerText;

                            if (messageText.trim().startsWith('!sor')) {
                                var question = messageText.trim().substring(4).trim();

                                
                                if (typeof axios === 'undefined') {
                                    var axiosScript = document.createElement('script');
                                    axiosScript.src = 'https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js';
                                    document.head.appendChild(axiosScript);

                                    axiosScript.onload = function() {
                                        processQuestion(question);
                                    };
                                } else {
                                    processQuestion(question);
                                }
                            }
                        }
                    }
                });
            }
        });
    });

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

    function processQuestion(question) {
        const apiKey = '662b8440-5c4c-43f4-9472-de6908640e71'; 
        const endpoint = 'https://api.deepai.org/api/text-generator';

        axios.post(endpoint, { text: question }, { headers: { 'api-key': apiKey } })
          .then(response => {
            const generatedResponse = response.data.output;

            const limits = [100, 150, 200, 250, 300];
            let parts = [];
            let remainingText = generatedResponse;

            for (const limit of limits) {
                const part = remainingText.substring(0, limit);
                parts.push(part);
                remainingText = remainingText.substring(limit).trim();
            }

            parts.forEach((part, index) => {
                setTimeout(() => {
                    inputText(part);
                    clickButton();
                }, index * 333); 
            });
          })
          .catch(error => {
            console.error('API Error:', error.response ? error.response.data : error.message);
          });
    }

    function inputText(text) {
        var inputElement = document.querySelector('input[name="chat"]');
        if (inputElement) {
            inputElement.value = text;
            inputElement.focus();

            var inputEvent = new Event('input', { bubbles: true });
            inputEvent.simulated = true;

            var valueTracker = inputElement._valueTracker;
            if (valueTracker) {
                valueTracker.setValue('');
            }

            inputElement.dispatchEvent(inputEvent);
        } else {
            console.error('Input element with name "chat" not found');
        }
    }

    function clickButton() {
        var yellowButton = document.querySelector('.btYellowBig.ic-chat');
        if (yellowButton) {
            yellowButton.click();
        } else {
            console.error('Button with class "btYellowBig.ic-chat" not found');
        }
    }
})();
Leave a Comment