NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name EnemyInfoFBC
// @description Enemy Information
// @copyright Kalish, 2020
// @namespace http://tampermonkey.net/
// @version 1.1
// @license MIT
// @author Kalish
// @match https://*.crownofthegods.com/
// @grant none
// ==/UserScript==
(function() {
'use strict';
function LoadSheet(sheet) {
return fetch(sheet)
.then((response) => {return response.text();})
.then((html) => {
let nome, data = new Array(), planilha = new DOMParser().parseFromString(html, "text/html");
planilha.querySelectorAll(".waffle > tbody").forEach(function(tbody, tabela) {
nome = planilha.querySelector("#sheet-menu") ? planilha.querySelectorAll("#sheet-menu > li > a")[tabela].innerHTML : planilha.querySelector("#doc-title > span").innerHTML.split(": ")[1];
data[nome] = [];
tbody.querySelectorAll("tr").forEach(function(tr, linha) {
data[nome].push([]);
tr.querySelectorAll("td").forEach(function(td, coluna) {
if(td.innerHTML) data[nome][linha].push(td.innerHTML);
else data[nome][linha].push("");
});
});
});
return data;
});
}
$("#cityplayerInfo").append("<div class='smallredheading'><small><p id='TropasAqui'></p><p id='FormLinkFBC'></p></small></div>");
const ObservarCidade = new MutationObserver(function() {
LoadSheet("https://docs.google.com/spreadsheets/d/e/2PACX-1vROcPMbJQwU4jC1Q3TeWGVJjl2kNnmox_yRaEXfGqomp_nUSZOq8WtPoeCKctrR3EPh6zdqZV95R4Oe/pubhtml").then(data => {
let EnemyTropasInfo;
data[Object.keys(data)[0]].forEach(function(entrada, index) {
if ($("#citycoords").text() == entrada[1]) EnemyTropasInfo = entrada;
});
(EnemyTropasInfo != null) ? $("#TropasAqui").html(EnemyTropasInfo[0].split("/")[1]+"/"+EnemyTropasInfo[0].split("/")[0]+": "+EnemyTropasInfo[2]) : $("#TropasAqui").text("No info");
$("#FormLinkFBC").html("<a href='https://docs.google.com/forms/d/e/1FAIpQLScns2mvyNo-lPNaAAdmtvvF5eh6nBh3DmMNKyfCm1qYPE2zxQ/viewform?entry.482060163="+$('#citycoords').text()+"' target='_blank'>Open in form</a>");
});
});
ObservarCidade.observe(document.querySelector("#citycoords"), {childList: true});
})();