// ==UserScript==
// @name Gaming helper
// @namespace http://tampermonkey.net/
// @version 0.1
// @description press Ctrl + F1 for the menu
// @author You
// @match https://shotwars.io/
// @icon https://tikstar-user-images.oss-cn-hongkong.aliyuncs.com/5c17_6687233396861682694.jpg
// @grant none
// ==/UserScript==
(function () {
"use strict";
// Some tools
function objectLenght(Object) {
let count = 0
for (const object in Object) {
count++
}
return count;
}
// Defining the HTML tool
class HTML {
constructor() {
this.HTMLObject = null;
}
create(type = '', style = '', innerHTML = '', placeholder = '', id = '') {
this.HTMLObject = document.createElement(type);
this.HTMLObject.style = style;
this.HTMLObject.innerHTML = innerHTML;
this.HTMLObject.placeholder = placeholder;
this.HTMLObject.id = id;
return this.HTMLObject;
}
onMouseHover(callback) {
this.HTMLObject.addEventListener("mouseover", callback);
}
onMouseQuit(callback) {
this.HTMLObject.addEventListener("mouseout", callback);
}
onMouseClick(callback) {
this.HTMLObject.onclick = callback;
}
HTMLapply(Elements, path = document.body, start = 0, end) {
if (end == undefined) {
end = objectLenght(Elements);
} else if (end < 0) {
end = objectLenght(Elements) + end;
}
this.a10(Elements, path, start, end)
}
a10(Elements, path, start, end) {
const elementsArray = Object.values(Elements);
for (let i = start; i < end; i++) {
path.appendChild(elementsArray[i]);
}
}
}
// Start coding...
const HTMLElement = new HTML;
let HTMLObjectsArray = {};
HTMLObjectsArray.Div = HTMLElement.create('div', 'left: 5px; top: 5px; position: absolute; background-color: black; box-shadow: #0983ce 0px 0px 7px 5px; display: block; z-index: 10; height: 500px; width: 340px;', '', '', 'Div');
HTMLObjectsArray.DivDisplayButton = HTMLElement.create('button', 'top: 5px; left: 5px; position: absolute; border-width: 0px; background-color: black; cursor: pointer; color: rgb(9, 131, 206); width: 32px; box-shadow: rgb(9 131 206) 0px 0px 0px 2px inset; display: block; z-index: 10;', '-', '', 'DivDisplayButton');
HTMLObjectsArray.changeNicknameP1 = HTMLElement.create('p', '', 'Change your nickname...', '', 'changeNicknameP1')
HTMLElement.onMouseHover(function () {
HTMLObjectsArray.DivDisplayButton.style.backgroundColor = "#183a4e";
});
HTMLElement.onMouseQuit(function () {
HTMLObjectsArray.DivDisplayButton.style.backgroundColor = "black";
});
HTMLElement.onMouseClick(function () {
if (HTMLObjectsArray.DivDisplayButton.innerHTML == '-') {
HTMLObjectsArray.DivDisplayButton.innerHTML = '+';
document.getElementById('Div').style.display = 'none';
} else if (HTMLObjectsArray.DivDisplayButton.innerHTML == '+') {
HTMLObjectsArray.DivDisplayButton.innerHTML = '-';
document.getElementById('Div').style.display = 'block';
};
});
HTMLElement.HTMLapply(HTMLObjectsArray);
})();