Bonk.io Fullscreen

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

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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);
    };
})();