101soundboards generator

Generate tts messages

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         101soundboards generator
// @namespace    [email protected]
// @version      2
// @description  Generate tts messages 
// @author       joshclark756
// @match        https://www.101soundboards.com/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    const minAmount = 290;
    const maxAmount = 300;

    function generateMessage(baseMessage) {
        const randomAmount = Math.floor(Math.random() * (maxAmount - minAmount + 1)) + minAmount;
        return `${baseMessage}`;
    }

    async function sendRequest(message, boardId) {
        const response = await fetch(`https://www.101soundboards.com/api/v1/boards/${boardId}/tts_phrase`, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({ phrase_text: message, gpt_requested: true })
        });
        return response.json();
    }

    function createGenerateButton() {
        const button = document.createElement('button');
        button.innerText = 'Generate';
        button.style.position = 'fixed';
        button.style.right = '20px';
        button.style.top = '100px'; // Adjusted position
        button.style.zIndex = '1000';
        document.body.appendChild(button);

        button.addEventListener('click', () => {
            const baseMessage = prompt("Enter your message:");
            const timesToGenerate = parseInt(prompt("How many times would you like to generate this message?"), 10);
            const urlParts = window.location.href.split('/');
            const boardId = urlParts[urlParts.length - 1].split('-')[0];
            if (baseMessage && !isNaN(timesToGenerate) && timesToGenerate > 0 && boardId) {
                for (let i = 0; i < timesToGenerate; i++) {
                    const message = generateMessage(baseMessage);
                    sendRequest(message, boardId);
                }
                alert(`Message successfully sent ${timesToGenerate} times`);
            }
        });
    }

    createGenerateButton();
})();