Greasy Fork 还支持 简体中文。

Bonk.io Chat

Chat with Bonk.io friends

  1. // ==UserScript==
  2. // @name Bonk.io Chat
  3. // @namespace http://tampermonkey.net/
  4. // @version 99.99
  5. // @description Chat with Bonk.io friends
  6. // @author You
  7. // @match https://bonk.io/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. // Function to send a message
  15. function sendMessage(username, message) {
  16. // Implement your logic to send a message
  17. console.log(`Sending message to ${username}: ${message}`);
  18. }
  19.  
  20. // Function to check online status
  21. function isUserOnline(username) {
  22. // Implement your logic to check if the user is online
  23. return true; // Replace with your actual check
  24. }
  25.  
  26. // Function to create a chat button
  27. function createChatButton(username) {
  28. const button = document.createElement('button');
  29. button.textContent = 'Chat';
  30. button.addEventListener('click', () => {
  31. if (isUserOnline(username)) {
  32. const message = prompt(`Send a message to ${username}`);
  33. if (message) {
  34. sendMessage(username, message);
  35. }
  36. } else {
  37. console.log(`${username} is offline right now.`);
  38. }
  39. });
  40. return button;
  41. }
  42.  
  43. // Function to find and add chat buttons
  44. function addChatButtons() {
  45. const friendList = document.querySelectorAll('.friend-list-item .name, .sideBarName'); // Adjust this selector based on Bonk.io's structure
  46.  
  47. if (friendList) {
  48. friendList.forEach((friend) => {
  49. const username = friend.textContent.trim();
  50. const chatButton = createChatButton(username);
  51. friend.parentNode.appendChild(chatButton);
  52. });
  53. }
  54. }
  55.  
  56. // Run the function once the page is fully loaded
  57. window.addEventListener('load', addChatButtons);
  58.  
  59. })();