Ai text detector

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

2023-10-18 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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         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)
    }
    
})();