DeepLuck
Co-Op Specialist
LEVEL 1
200 XP
Hello users, I just made this script for @ to help him to use the shoutbox and did some fix in the code using GPT since he's in recover from an accident and I'm glad I could help. I wanted to share the code with you if you're interested to have a button near the emotes that sends a message.
It's not the best button, or the coolest
It should look like this in the end:
It's not the best button, or the coolest
Code:
// ==UserScript==
// @name Cracked.io Shoutbox Send Button
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Adds a send button to the shoutbox on cracked.io
// @author Cracked.io/Alex
// @match
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Function to simulate pressing the Enter key
function sendMessage() {
let messageInput = document.querySelector('#message_input');
if (messageInput && messageInput.value.trim().length > 0) {
let event = new KeyboardEvent('keypress', {
bubbles: true,
cancelable: true,
keyCode: 13
});
messageInput.dispatchEvent(event);
}
}
// Create the Send button
function addButton() {
let button = document.createElement('button');
button.innerHTML = 'Send';
button.style.position = 'relative';
button.style.marginLeft = '10px';
button.style.padding = '5px 10px';
button.style.backgroundColor = '#4E4E4E';
button.style.color = 'white';
button.style.border = 'none';
button.style.cursor = 'pointer';
button.style.borderRadius = '4px';
button.addEventListener('click', function() {
sendMessage();
});
// Add the button to the page
let inputContainer = document.querySelector('#shoutbox #message_input').parentElement;
if (inputContainer) {
inputContainer.appendChild(button);
}
}
// Wait for the shoutbox to load
function waitForShoutbox() {
let shoutbox = document.querySelector('#shoutbox');
if (shoutbox) {
addButton();
} else {
setTimeout(waitForShoutbox, 500);
}
}
waitForShoutbox();
})();