battledudes.io chat

Opens chat to talk together while playing.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला 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";
		}
	}
})
})();