battledudes.io chat

Opens chat to talk together while playing.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==
// @name         battledudes.io chat
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  Opens chat to talk together while playing.
// @author       blah_blah1.
// @match        *://*.battledudes.io/*
// @license      MIT
// @icon         https://ibb.co/gZBRkFjb
// @grant        none
// ==/UserScript==

(function() {
'use strict'

   window.addEventListener("load", () => {
	const allButtons = document.getElementsByClassName("button")
	
	for (var i = 0; i < allButtons.length; i++) {
		const button = allButtons[i];

		if (button.innerText.includes("Play")) {
			button.addEventListener("click", () => {
				const encoded = localStorage.getItem("dg2_gameDisplayName");
	
				const nameValue = atob(encoded);
				
				const iframe = document.createElement("iframe");
				iframe.src = `https://battledudes-chat.vercel.app/?name=${nameValue.replaceAll("%22", "")}`;
				iframe.className = "chat-iframe";
				iframe.style.width = "500px";
				iframe.style.height = "500px";
				iframe.style.position = "fixed";
				iframe.style.top = 0;
				iframe.style.right = 0;
				iframe.style.display = "block";
				iframe.style.zIndex = 9999

				document.body.appendChild(iframe);
			});
		}
	}
	
	})

document.addEventListener("keydown", e => {
	if (e.key == "c" || e.key == "C") {
		const chatElement = document.getElementsByClassName("chat-iframe")[0];
		if (chatElement) {
			chatElement.style.display = chatElement.style.display == "none" ? "block" : "none";
		}
	}
})
})();