Ai text detector

Check if the selected text is written with an AI using the zerogpt API

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey, Greasemonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Violentmonkey.

Чтобы установить этот скрипт, вы сначала должны установить расширение браузера, например Tampermonkey или Userscripts.

Чтобы установить этот скрипт, сначала вы должны установить расширение браузера, например Tampermonkey.

Чтобы установить этот скрипт, вы должны установить расширение — менеджер скриптов.

(у меня уже есть менеджер скриптов, дайте мне установить скрипт!)

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение браузера, например Stylus.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

Чтобы установить этот стиль, сначала вы должны установить расширение — менеджер стилей.

(у меня уже есть менеджер стилей, дайте мне установить скрипт!)

// ==UserScript==
// @name         Ai text detector
// @namespace    [email protected]
// @version      1
// @description  Check if the selected text is written with an AI using the zerogpt API
// @include      *
// @grant        GM_xmlhttpRequest
// @license      GPLv3
// ==/UserScript==

(function() {
    'use strict';

    document.onmouseup = function() {
        var text = getSelectionText();
        if (text) {
            sendPostRequest(text);
        }
    };

    function getSelectionText() {
        var text = "";
        if (window.getSelection) {
            text = window.getSelection().toString();
        } else if (document.selection && document.selection.type != "Control") {
            text = document.selection.createRange().text;
        }
        return text;
    }

    function sendPostRequest(text) {
        var data = {
            "input_text": text
        };
        console.log("Sending POST request with data:", data);
        GM_xmlhttpRequest({
            method: "POST",
            url: "https://api.zerogpt.com/api/detect/detectText",
            headers: {
                "Host": "api.zerogpt.com",
                "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36",
                "Accept": "application/json, text/plain, */*",
                "Accept-Language": "en-US,en;q=0.5",
                "Accept-Encoding": "gzip, deflate, br",
                "Content-Type": "application/json",
                "Origin": "https://www.zerogpt.com",
                "DNT": "1",
                "Connection": "keep-alive",
                "Referer": "https://www.zerogpt.com/",
                "Sec-Fetch-Dest": "empty",
                "Sec-Fetch-Mode": "cors",
                "Sec-Fetch-Site": "same-site",
                "Sec-GPC": "1",
                "TE": "trailers"
            },
            data: JSON.stringify(data),
            onload: function(response) {
                var res = JSON.parse(response.responseText);
                console.log("POST request response:", res);
                if (res.success==true){
                    simulateNotification("The selected text has a " + res.data.fakePercentage + "% chance of being generated by an AI");
                }
            }
        });
    }
    function simulateNotification(title, message) {
        var notificationContainer = document.createElement("div");
        notificationContainer.style.cssText = `position: fixed;
        top: 10px;
        right: 10px;
        background-color: #282828; /* Background color for Gruvbox palette */
        color: #ebdbb2; /* Text color for Gruvbox palette */
        border: 1px solid #3c3836; /* Border color for Gruvbox palette */
        padding: 10px;
        box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
        z-index: 9999;
        opacity: 1;
        transition: opacity 1s, border-radius 0.5s;
        border-radius: 5px; /* Rounded corners */";
        `
        var notificationTitle = document.createElement("div");
        notificationTitle.textContent = title;
        notificationTitle.style.fontWeight = "bold";

        var notificationMessage = document.createElement("div");
        notificationMessage.textContent = message;

        notificationContainer.appendChild(notificationTitle);
        notificationContainer.appendChild(notificationMessage);
        document.body.appendChild(notificationContainer);

        // Set a timer to fade out the notification after 5 seconds
        setTimeout(function() {
            notificationContainer.style.opacity = 0;
            setTimeout(function() {
                document.body.removeChild(notificationContainer);
            }, 500); // Remove the notification after the fade-out animation (adjust as needed)
        }, 3000); // Start the fade-out animation after 5 seconds (adjust as needed)
    }
    
})();