Skip to content

Instantly share code, notes, and snippets.

@BeardedBear
Last active March 31, 2022 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BeardedBear/765780e7627454569595a1e53a034db3 to your computer and use it in GitHub Desktop.
Save BeardedBear/765780e7627454569595a1e53a034db3 to your computer and use it in GitHub Desktop.

BAGAR

Affiche le tableau des éléments en dessous du tchat pour jouer a BAGAR sur la page Twitch de Shakawah:

image

Installation

// ==UserScript==
// @name BAGAR
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author @BeardedBear
// @match https://www.twitch.tv/shakawah
// @icon https://www.google.com/s2/favicons?sz=64&domain=twitch.tv
// @grant none
// ==/UserScript==
(function() {
"use strict";
const data = {
"water" : [0,-3,2,3,-2,1,2,-1,-2,0,0,-2,2,-2,1,2,-1],
"fire" : [3,0,-2,2,-3,-1,0,-2,3,-3,-2,3,2,2,2,-2,-2],
"wood" : [-2,2,0,-3,3,2,-1,1,-2,3,-1,-2,0,2,-1,-2,1],
"earth" : [-3,-2,3,0,2,0,-3,0,3,3,0,0,-3,-2,0,2,0],
"metal" : [2,3,-3,-2,0,0,1,-1,0,3,0,0,-3,2,1,-1,-2],
"ice" : [-1,1,-2,0,0,0,2,-2,2,3,0,-1,-2,-2,3,-1,0],
"thunder" : [-2,0,1,3,-1,-2,0,2,-1,-3,2,1,0,-2,2,0,0],
"wind" : [1,2,-1,0,1,2,-2,0,-3,0,-2,0,2,-2,-1,3,0],
"darkness" : [2,-3,2,-3,0,-2,1,3,0,-3,3,-1,1,-2,-3,2,3],
"cristal" : [0,3,-3,-3,-3,-3,3,0,3,0,0,0,3,-3,-3,3,3],
"mist" : [0,2,1,0,0,0,-2,2,-3,0,0,0,0,2,-1,1,-2],
"rock" : [2,-3,2,0,0,1,-1,0,1,0,0,0,-2,2,-2,1,-1],
"sand" : [-2,-2,0,3,3,2,0,-2,-1,-3,0,2,0,-2,0,0,2],
"acide" : [2,-2,-2,2,-2,2,2,2,2,3,-2,-2,2,0,-2,-2,-3],
"salt" : [-1,-2,1,0,-1,-3,-2,1,3,3,1,2,0,2,0,-3,-1],
"fungal" : [-2,2,2,-2,1,1,0,-3,-2,-3,-1,-1,0,2,3,0,3],
"vermin" : [1,2,-1,0,2,0,0,0,-3,-3,2,1,-2,3,1,-3,0]
};
function createCase(key, value, index){
const c = document.createElement("div");
c.style.height = "11px";
c.style.border = "1px solid #18181b";
c.style.fontSize = "0.7rem";
c.style.textAlign = "center";
c.style.color = "black";
c.style.fontWeight = "bold";
c.style.textTransform = "uppercase";
if (index === 9 - 1 || index === 13 - 1){
c.style.marginBottom = "3px";
}
if (value === -3) {
c.style.backgroundColor = "#3c3c42";
c.style.opacity = "0.7";
c.style.color = "#da4141";
c.innerText = key.slice(0, 3);
} else if (value === -2) {
c.style.backgroundColor = "#3c3c42";
c.style.opacity = "0.7";
c.style.color = "#da4141";
c.innerText = key.slice(0, 3);
} else if (value === -1) {
c.style.backgroundColor = "#3c3c42";
c.style.opacity = "0.7";
c.style.color = "#da4141";
c.innerText = key.slice(0, 3);
} else if (value === 1) {
c.style.backgroundColor = "#42892a";
c.innerText = key.slice(0, 3);
} else if (value === 2) {
c.style.backgroundColor = "#2fc85b";
c.innerText = key.slice(0, 3);
} else if (value === 3) {
c.style.backgroundColor = "#9ffea0";
c.innerText = key.slice(0, 3);
} else {
c.style.backgroundColor = "#3c3c42";
}
return c
}
function createCol(key, values, index) {
const label = document.createElement("div")
label.innerText = key.slice(0, 3);
label.style.fontSize = "0.7rem";
label.style.textAlign = "center";
label.style.fontWeight = "bold";
label.style.textTransform = "uppercase";
const col = document.createElement("div");
col.appendChild(label);
col.style.flex = "1";
if (index === 9 - 1 || index === 13 - 1){
col.style.marginRight = "3px";
}
values.forEach((value, index) => {
col.appendChild(createCase(Object.entries(data)[index][0], value, index));
})
return col
}
setTimeout(() => {
const parent = document.createElement("div");
parent.style.display = "flex"
Object.entries(data).forEach(([key, values], index) => {
parent.appendChild(createCol(key, values, index))
})
document.querySelector(".chat-room__content").appendChild(parent);
}, 3000)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment