afk thing

be afk twin

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name        afk thing
// @namespace   Violentmonkey Scripts
// @icon        https://classic.talkomatic.co/images/icons/favicon.png
// @version     1.0.0
//
// @match       https://classic.talkomatic.co/room.html*
// @grant       none
//
// @author      paul
// @description be afk twin
// @license     MIT
// ==/UserScript==

(function() {
    'use strict';

    function injectButton(navbar) {
        const text = `${currentUsername} is AFK, please wait`
        if (document.getElementById('afk-field')) return;

        const buttonContainer = document.createElement('div');
        buttonContainer.id = 'afk-field';
        buttonContainer.style.display = 'inline-block';
        buttonContainer.style.margin = '0 5px';

        // Injected HTML block with your exact CSS inline styles added
        buttonContainer.innerHTML = `
            <button
                style="font-size: 14px; cursor: pointer; background-color: black; color: white; border: 1px solid #ff9800; padding: 10px; border-radius: 5px; font-family: talkoSS, Arial, sans-serif; white-space: nowrap;"
                onmousedown="socket.emit('chat update', {diff: {type: "full-replace", text: text}})">
                Announce AFK
            </button>
        `.trim();

        navbar.appendChild(buttonContainer);
    }

    const observer = new MutationObserver((mutations, obs) => {
        const pageContainer = document.querySelector('div.page-container, #page-container');
        if (pageContainer) {
            const navbar = pageContainer.querySelector('nav.top-navbar, #top-navbar');
            if (navbar) {
                injectButton(navbar);
            }
        }
    });

    observer.observe(document.documentElement, {
        childList: true,
        subtree: true
    });
})();