tanksmith.io custom unit menu

read the title

Από την 18/02/2022. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        tanksmith.io custom unit menu
// @namespace   http://bzzzzdzzzz.blogspot.com/
// @description read the title
// @author      BZZZZ
// @include     /^https?\:\/\/(www\.)?tanksmith\.io\/([?#]|$)/
// @version     0.11
// @grant       none
// @run-at      document-end
// @inject-into content
// ==/UserScript==
 
{
const a=document.createElement("div");
a.setAttribute("onclick",`"use strict";
	document.head.insertAdjacentHTML("beforeend","<style>#store>div{display:none;}</style>");
	const mnames=["Wood","Iron","Gold","Diamond","Amethyst"],unames=["Basic\\xA0Unit","Basic\\xA0Turret","Sniper\\xA0Turret","Twin\\xA0Turret","Cannon\\xA0Turret","Healing\\xA0Unit","Alchemy\\xA0Lab","Booster\\xA0Unit","Octa\\xA0Turret","Spike"],ucost=[6,8,10,10,18,14,20,12,16,8],store=document.getElementById("store");
	const mselectedcolor="#00FF00",munselectedcolor="#FFFF00",textcolor="#000000",cursor="pointer",mselect=function(){
		mselected.style.backgroundColor=munselectedcolor;
		mselected=this;
		this.style.backgroundColor=mselectedcolor;
	},uselect=function(){
		document.getElementById("u:1;0").onclick.call({"id":\`u:\${this.dataset.id};\${mselected.dataset.id}\`});
	},setcostdisplay=function(){
		const m=parseInt(mselected.dataset.id);
		costdisplay.textContent=\`\${(1+m)*ucost[parseInt(this.dataset.id)-1]} \${mnames[m]}\`;
	},clearcostdisplay=()=>costdisplay.textContent="";
	let mselected=document.createElement("span");
	mselected.style.backgroundColor=mselectedcolor;
	mselected.style.color=textcolor;
	mselected.style.cursor=cursor;
	mselected.textContent=mnames[0];
	mselected.onclick=mselect;
	mselected.dataset.id="0";
	store.appendChild(mselected);
	let i=1,span;
	while(i<5){
		store.appendChild(document.createTextNode(" "));
		span=document.createElement("span");
		span.style.backgroundColor=munselectedcolor;
		span.style.color=textcolor;
		span.style.cursor=cursor;
		span.textContent=mnames[i];
		span.onclick=mselect;
		span.dataset.id=i++;
		store.appendChild(span);
	}
	store.appendChild(document.createElement("hr"));
	span=document.createElement("span");
	span.style.backgroundColor=munselectedcolor;
	span.style.color=textcolor;
	span.style.cursor=cursor;
	span.textContent=unames[0];
	span.onclick=uselect;
	span.onmouseenter=setcostdisplay;
	span.onmouseleave=clearcostdisplay;
	span.dataset.id="1";
	store.appendChild(span);
	i=1;
	while(i<10)if(i===7/*booster unit*/)i++;else{
		store.appendChild(document.createTextNode(" "));
		span=document.createElement("span");
		span.style.backgroundColor=munselectedcolor;
		span.style.color=textcolor;
		span.style.cursor=cursor;
		span.textContent=unames[i++];
		span.onclick=uselect;
		span.onmouseenter=setcostdisplay;
		span.onmouseleave=clearcostdisplay;
		span.dataset.id=i;
		store.appendChild(span);
	}
	store.appendChild(document.createElement("hr"));
	const costdisplay=document.createElement("span");
	costdisplay.style.color="#FFFFFF";
	store.appendChild(costdisplay);`);
a.click();
}