您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Simply reroll result automatically since all free service are completed shit
// ==UserScript== // @name janitorai reroll // @namespace http://tampermonkey.net/ // @version 1.04 // @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 numberCurrentReroll = 0; 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 */font-size: 18px;}.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">×</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 minimum (Number of characters): <input type="number" id="my-length-response" value="200"><br>Number of maximum reroll allows: <input type="number" id="my-number-reroll" value="50"><br><div>In progress: </div><div id="in-progress">❌</div> <div id="my-number-of-reroll"></div><br><input type="button" id="my-reroll-button" value="Start Reroll"> <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"); var divRerollNumber = document.getElementById("my-number-of-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; numberCurrentReroll = 0; document.getElementById("in-progress").innerText = "✅"; divRerollNumber.textContent = ""; 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; let randomNumber = Math.floor(Math.random() * 5); if(!randomInterval) randomNumber = 0; timeoutId = setTimeout(_ => { try { listOfMessage = document.querySelectorAll('div[data-index]');//If message error type interfere, may need more precise code here 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){ console.log("error:"); console.log(error); /* //Keeping this here, if I rather still doing rerolling if there unknow 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--; divRerollNumber.textContent = "Reroll commited: " + (numberRetry - retries); inProgress = false; }, (intervalTime + randomNumber) * 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); } })();