Bonk.io Chat

Chat with Bonk.io friends

当前为 2024-01-20 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bonk.io Chat
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Chat with Bonk.io friends
// @author       You
// @match        https://bonk.io/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to send a message
    function sendMessage(username, message) {
        // Implement your logic to send a message
        console.log(`Sending message to ${username}: ${message}`);
    }

    // Function to check online status
    function isUserOnline(username) {
        // Implement your logic to check if the user is online
        return true; // Replace with your actual check
    }

    // Function to create a chat button
    function createChatButton(username) {
        const button = document.createElement('button');
        button.textContent = 'Chat';
        button.addEventListener('click', () => {
            if (isUserOnline(username)) {
                const message = prompt(`Send a message to ${username}`);
                if (message) {
                    sendMessage(username, message);
                }
            } else {
                console.log(`${username} is offline right now.`);
            }
        });
        return button;
    }

    // Function to find and add chat buttons
    function addChatButtons() {
   const friendList = document.querySelectorAll('.friend-list-item .name'); // Adjust this selector based on Bonk.io's structureust this selector based on Bonk.io's structure

        if (friendList) {
            friendList.forEach((friend) => {
                const username = friend.textContent.trim();
                const chatButton = createChatButton(username);
                friend.parentNode.appendChild(chatButton);
            });
        }
    }

    // Run the function once the page is fully loaded
    window.addEventListener('load', addChatButtons);

})();