Bonk Clear Chat

Adds a button to clear chat

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Bonk Clear Chat
// @version      1.1
// @author       Salama
// @description  Adds a button to clear chat
// @match        https://*.bonk.io/gameframe-release.html
// @run-at       document-start
// @grant        none
// @supportURL   https://discord.gg/Dj6usq7ww3
// @namespace    https://greasyfork.org/users/824888
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    let button = document.createElement('div');
    document.getElementById("newbonklobby_chatbox").getElementsByClassName("newbonklobby_boxtop newbonklobby_boxtop_classic")[0].appendChild(button);
    button.outerHTML = `<div id="clearchatbutton" class="brownButton brownButton_classic buttonShadow" style="line-height: 24px;visibility: inherit;margin: 0;top: 4;left: 4;font-family: 'futurept_b1';font-size: 16px;width: 100px;height: 24px;position: absolute;">CLEAR</div>`;
    document.getElementById("clearchatbutton").addEventListener('click', () => {
        for(let msg of [...document.getElementById("newbonklobby_chat_content").children].concat([...document.getElementById("ingamechatcontent").children])) {
            msg.remove();
        }
    });
    console.log("Clear chat button added");
})();