add the add friends to a button for the userscript

// Define the request function
async function fetchAndAddFriends() {
  try {
    // Send the POST request
    const response = await fetch("https://furrychat.net/chat/system/panel/user_list.php", {
      method: "POST",
      headers: {
        "accept": "*/*",
        "accept-language": "en-US,en;q=0.9,ru;q=0.8",
        "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
        "cookie": "bc_userid=26388; bc_utk=0753dc00de8f82819cdbbffeea2f0e574ce8ea39; PHPSESSID=11h1kn9k2os2te9a3vvic1j9bs",
        "origin": "https://furrychat.net",
        "referer": "https://furrychat.net/chat/",
        "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36",
        "x-requested-with": "XMLHttpRequest"
      },
      body: new URLSearchParams({
        "token": "b40f4fb84a60ab3a58b6d700f38eeb65"
      })
    });

    // Get the HTML response as text
    const html = await response.text();

    // Create a temporary DOM parser
    const parser = new DOMParser();
    const doc = parser.parseFromString(html, 'text/html');

    // Select all elements containing the `dropUser` function call
    const userElements = doc.querySelectorAll("[onclick^='dropUser']");

    // Extract IDs and call addFriend(ID) for each
    userElements.forEach(element => {
      const onclickAttr = element.getAttribute("onclick");
      const idMatch = onclickAttr.match(/dropUser\(this,(\d+),/);
      if (idMatch) {
        const userID = idMatch[1];
        console.log(`Calling addFriend(${userID})`);
        addFriend(userID);  // Call addFriend with each user ID
      }
    });

  } catch (error) {
    console.error("Error fetching user list:", error);
  }
}



// Run the function
fetchAndAddFriends();


// ==UserScript==
// @name         FurryChat Enhanced
// @namespace    http://tampermonkey.net/
// @version      1.2
// @description  Even Better FC
// @author       You
// @match        https://furrychat.net/chat/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // --- Settings Panel ---
    var settingsPanel = `
        <div id="reload-settings" style="position: fixed; bottom: 20px; right: 20px; background-color: #fff; border: 1px solid #ccc; padding: 10px; z-index: 9999;">
            <h3>Chat Settings</h3>
            Reload Speed: <input type="range" id="reload-slider" min="100" max="5000" value="${speed}" step="100">
            <span id="reload-value">${speed}</span> ms<br>
            <button id="pause-button" style="background-color: blue; color: white; border: none; padding: 5px 10px; cursor: pointer;">Pause</button>
        </div>
    `;
    $('body').append(settingsPanel);


    // --- Pause Functionality ---
    var isPaused = false;
    $('#pause-button').on('click', function() {
        isPaused = !isPaused;  // Toggle pause state
        $(this).text(isPaused ? 'Resume' : 'Pause');

        if (isPaused) {
            clearInterval(chatLog); // Stop the interval
            console.log("Chat paused");
        } else {
            chatLog = setInterval(chatReload, speed); // Restart the interval
            chatReload(); // Force an immediate reload
            console.log("Chat resumed");
        }
    });


    // --- Reload Speed Slider ---
    $('#reload-slider').on('input', function() {
        speed = parseInt($(this).val());
        $('#reload-value').text(speed);
        localStorage.setItem('fcReloadSpeed', speed); // Save to localStorage

        if (!isPaused) { // Only restart if not paused
            clearInterval(chatLog);
            chatLog = setInterval(chatReload, speed);
            console.log("Chat reload speed set to:", speed);
        }
    });


    // --- Load Settings on Startup ---
    let storedSpeed = localStorage.getItem('fcReloadSpeed');
    if (storedSpeed) {
        speed = parseInt(storedSpeed);
        $('#reload-slider').val(speed);
        $('#reload-value').text(speed);

        if (!isPaused) { // Set interval with stored speed if not paused
            clearInterval(chatLog);
            chatLog = setInterval(chatReload, speed);
        }
    }


    // --- Observe 'speed' for changes (for initial setup) ---
    let speedObserver = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            if (mutation.type === 'characterData' && mutation.target.nodeValue) {
                localStorage.setItem('fcReloadSpeed', mutation.target.nodeValue);
            }
        });
    });

    let speedElement = document.getElementById('reload-value').firstChild;
    if (speedElement) {
        speedObserver.observe(speedElement, { characterData: true, subtree: true });
    }

})();