janitorai reroll

Simply reroll result automatically since all free service are completed shit

当前为 2025-08-28 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         janitorai reroll
// @namespace    http://tampermonkey.net/
// @version      1.00
// @description  Simply reroll result automatically since all free service are completed shit
// @author       James
// @icon         https://ella.janitorai.com/hotlink-ok/logo.png
// @license      MIT
// @match        https://janitorai.com/chats/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var inProgress = false;
    var lastMessageText;
    var receivedResponse = false;
    var stop = false;

    var intervalTime = 10;
    var randomInterval = true;
    var responseLength = 200;
    var numberRetry = 50;

    var style = document.createElement('style');
    style.innerHTML = 'body {font-family: Arial, Helvetica, sans-serif;}.my-modal-reroll {display: none; /* Hidden by default */position: fixed; /* Stay in place */z-index: 20; /* Sit on top */padding-top: 100px; /* Location of the box */left: 0;top: 0;width: 100%; /* Full width */height: 100%; /* Full height */overflow: auto; /* Enable scroll if needed */background-color: rgb(0,0,0); /* Fallback color */background-color: rgba(0,0,0,0.4); /* Black w/ opacity */}.my-modal-content-reroll {background-color: black;margin: auto;padding: 20px;border: 1px solid #888;width: 80%;color: #42b01a}.my-close-reroll {color: #aaaaaa;float: right;font-size: 28px;font-weight: bold;}.my-close-reroll:hover,.my-close-reroll:focus {color: red;text-decoration: none;cursor: pointer;}';
    document.head.appendChild(style);

    var elemDiv = document.createElement('div');
    document.body.appendChild(elemDiv);
    elemDiv.innerHTML = '<div id="myModalReroll" class="my-modal-reroll"><div class="my-modal-content-reroll"><span id="my-close-reroll" class="my-close-reroll">&times;</span>Lenght of time (In seconds): <input type="number" id="my-interval-time" value="10"><br>Random interval add (Add 1-5 second to every attempt): <input id="my-random-interval-time" type="checkbox" checked=true><br>Length response (Number of characters): <input type="number" id="my-length-response" value="200"><br>Number of reroll: <input type="number" id="my-number-reroll" value="50"><br><div>In progress: </div><div id="in-progress">❌</div><br><input type="button" id="my-reroll-button" value="Submit">  <input type="button" id="my-reroll-button-stop" value="Stop"></div></div>';

    var modal = document.getElementById("myModalReroll");
    var btn = document.getElementById("myButtonModal");
    var span = document.getElementById("my-close-reroll");

    span.onclick = function() {
        modal.style.display = "none";//The x button to close
    }

    window.onclick = function(event) {
        if (event.target == modal) {
            modal.style.display = "none";//When the user clicks anywhere outside of the modal, close it
        }
    }

    document.onkeydown = function(){
        if(window.event && window.event.keyCode == 112)//F1 keyboard listen
        {
            modal.style.display = "block";//Hidden button to active pop-up
        }
    }

    var myRerollButton = document.getElementById("my-reroll-button");
    myRerollButton.onclick = function() { startRerolling();};

    var myRerollButtonStop = document.getElementById("my-reroll-button-stop");
    myRerollButtonStop.onclick = function() { stopOperation();};

    var listOfMessage;
    var newestMessage;
    var timeoutId;
    var intervalID;

    function startRerolling(){
        myRerollButton.disabled = true;
        document.getElementById("in-progress").innerText = "✅";
        listOfMessage = document.querySelectorAll('[data-index]');
        lastMessageText = listOfMessage[listOfMessage.length - 1].getElementsByClassName('css-ji4crq')[listOfMessage[listOfMessage.length - 1].getElementsByClassName('css-ji4crq').length - 1].outerText;

        intervalTime = parseInt(document.getElementById("my-interval-time").value);
        randomInterval = document.getElementById("my-random-interval-time").checked;
        responseLength = parseInt(document.getElementById("my-length-response").value);
        numberRetry = parseInt(document.getElementById("my-number-reroll").value);

        if(randomInterval){
            intervalTime = intervalTime + Math.floor(Math.random() * 5);
        }

        if(Number.isInteger(intervalTime) && Number.isInteger(responseLength) && Number.isInteger(numberRetry)){
            let retries = numberRetry;//open router daily or gemini, you could change it to higher if you got prenium in either

            intervalID = setInterval(_ => {
                if(document.getElementsByClassName('_stopButton_17cr1_1').length == 0){//Stop button doesn't exist, which mean we are not waiting for a response anymore
                    if(!inProgress){
                        inProgress = true;

                        timeoutId = setTimeout(_ => {

                            try {
                                listOfMessage = document.querySelectorAll('[data-index]');
                                newestMessage = listOfMessage[listOfMessage.length - 1].getElementsByClassName('css-ji4crq')[listOfMessage[listOfMessage.length - 1].getElementsByClassName('css-ji4crq').length - 1];//We need to check if response is minimum length wanted
                                if(lastMessageText != newestMessage.outerText && newestMessage.outerText.length >= responseLength){//response different and of comfort minimum lenght, This mean all reroll gave a succesful response otherwise we keep going
                                    stopOperation();
                                }else{
                                    if(document.getElementsByClassName('_botChoiceButton_nr7g7_21 _right_nr7g7_39').length != 0){//Reroll button from response
                                        document.getElementsByClassName('_botChoiceButton_nr7g7_21 _right_nr7g7_39')[0].click();
                                    }
                                    if(document.querySelectorAll('[aria-label="Re-generate last answer"]').length != 0){//Reroll button from message
                                        document.querySelectorAll('[aria-label="Re-generate last answer"]')[0].click();
                                    }
                                }
                            } catch(error){
                                if(document.getElementsByClassName('_botChoiceButton_nr7g7_21 _right_nr7g7_39').length != 0){//Reroll button from response
                                    document.getElementsByClassName('_botChoiceButton_nr7g7_21 _right_nr7g7_39')[0].click();
                                }
                                if(document.querySelectorAll('[aria-label="Re-generate last answer"]').length != 0){//Reroll button from message
                                    document.querySelectorAll('[aria-label="Re-generate last answer"]')[0].click();
                                }
                            }

                            retries--;

                            inProgress = false;

                        }, (intervalTime + Math.floor(Math.random() * 5)) * 1000);//Transform second to millisecond

                    }

                }

                if(retries <= 0){
                    stopOperation();

                }
            }, 2000);//Every 2 second check current status

        }

    }

    function stopOperation(){
        document.getElementById("in-progress").innerText = "❌";
        inProgress = false;
        myRerollButton.disabled = false;
        clearTimeout(timeoutId);
        clearInterval(intervalID);
    }

})();