Bonk.io Fullscreen

A simpler, and less laggy fullscreen button for Bonk.io.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Bonk.io Fullscreen
// @namespace    http://tampermonkey.net/
// @version      2025-03-29
// @description  A simpler, and less laggy fullscreen button for Bonk.io.
// @author       You
// @match        https://bonk.io
// @icon         https://bonk.io/graphics/tt/favicon-32x32.png
// @license MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.onload = function() {
        const frame = document.getElementById("maingameframe").contentWindow;
        const container = frame.document.getElementById("bonkiocontainer");

        const style = document.createElement("style");
        style.textContent = `
          canvas {
            display: block;
            margin: auto;
          }
        `;

        frame.document.head.appendChild(style);

        const button = document.createElement("button");
        button.innerHTML = "Fullscreen";

        Object.assign(button.style, {
            position: "absolute",
            left: "0px",
            lineHeight: "31px",
            background: "none",
            border: "none",
            color: "rgb(255 255 255 / 25%)",
            fontFamily: "futurept_b1",
            fontSize: "17px",
            cursor: "pointer",
        });

        button.addEventListener("click", () => {
            if (container.requestFullscreen) {
                container.requestFullscreen();
            } else if (container.mozRequestFullScreen) {
                container.mozRequestFullScreen();
            } else if (container.webkitRequestFullscreen) {
                container.webkitRequestFullscreen();
            } else if (container.msRequestFullscreen) {
                container.msRequestFullscreen();
            }
        });

        const header = document.getElementById("bonkioheader");
        header.appendChild(button);
    };
})();