Fix messages display
This commit is contained in:
@@ -30,15 +30,13 @@ function createRow(key, value) {
|
||||
}
|
||||
|
||||
function shortcutElementReplace(elt, img, text) {
|
||||
hyperlinkElements = elt.getElementsByTagName("a");
|
||||
if (hyperlinkElements.length == 2) {
|
||||
hyperlinkElements[0].remove();
|
||||
elt.getElementsByTagName("a")[0].classList.add("has_notif");
|
||||
}
|
||||
imageElements = elt.getElementsByTagName("img");
|
||||
if (imageElements.length == 1 && imageElements[0].getAttribute("src").endsWith("new_report.png")) {
|
||||
imageElements[0].remove();
|
||||
elt.getElementsByTagName("a")[0].classList.add("has_notif");
|
||||
imgElements = elt.getElementsByTagName("img")
|
||||
for (i=0; i<imgElements.length; i++) {
|
||||
if (i == 0) {
|
||||
elt.getElementsByTagName("a")[0].classList.add("has_notif");
|
||||
}
|
||||
imgElements[i].remove();
|
||||
i --;
|
||||
}
|
||||
|
||||
spanImageElement = document.createElement("span");
|
||||
@@ -60,48 +58,11 @@ function shortcutElementReplace(elt, img, text) {
|
||||
}
|
||||
}
|
||||
|
||||
function shortcutElementAddFlag(elt, side) {
|
||||
shortcutContainer = document.createElement("div");
|
||||
shortcutContainer.classList.add("shortcut_container", "shortcut_container_flag", "shortcut_container_flag_"+side);
|
||||
shortcutElement = document.createElement("div");
|
||||
shortcutElement.classList.add("shortcut_element");
|
||||
shortcutElementCenter = document.createElement("span");
|
||||
shortcutElementCenter.classList.add("shortcut_element_center");
|
||||
shortcutElementMarker = document.createElement("span");
|
||||
shortcutElementMarker.classList.add("shortcut_element_marker");
|
||||
|
||||
hyperlink = document.createElement("a");
|
||||
hyperlink.classList.add("no_attack");
|
||||
|
||||
spanImage = document.createElement("span");
|
||||
spanImage.classList.add("shortcut_element_image");
|
||||
image = document.createElement("img");
|
||||
image.setAttribute("src", chrome.runtime.getURL("images/flag.svg"));
|
||||
|
||||
spanDesc = document.createElement("span");
|
||||
spanDesc.classList.add("shortcut_element_desc");
|
||||
|
||||
layTowerAttacks = document.getElementsByClassName("lay_tower_"+side+"_top_attack");
|
||||
if (layTowerAttacks.length == 1) {
|
||||
hyperlink.setAttribute("href", layTowerAttacks[0].getElementsByTagName("a")[0].getAttribute("href"));
|
||||
spanDesc.textContent = layTowerAttacks[0].textContent;
|
||||
hyperlink.classList.add("has_attack");
|
||||
hyperlink.classList.remove("no_attack");
|
||||
}
|
||||
|
||||
spanImage.appendChild(image);
|
||||
hyperlink.appendChild(spanImage);
|
||||
hyperlink.appendChild(spanDesc);
|
||||
shortcutElementMarker.appendChild(hyperlink);
|
||||
shortcutElementCenter.appendChild(shortcutElementMarker);
|
||||
shortcutElement.appendChild(shortcutElementCenter);
|
||||
shortcutContainer.appendChild(shortcutElement);
|
||||
elt.appendChild(shortcutContainer);
|
||||
}
|
||||
|
||||
/* Improve main menu display */
|
||||
layCastleTopElements = document.getElementsByClassName("lay_castle_top");
|
||||
if (layCastleTopElements.length == 1) {
|
||||
document.getElementById("banner_skyscraper").remove();
|
||||
|
||||
shortcutElements = layCastleTopElements[0].getElementsByClassName("shortcut_element");
|
||||
shortcutElementReplace(shortcutElements[0], "ranking", shortcutElements[0].textContent.replace(/[^0-9]/g, ""));
|
||||
shortcutElementReplace(shortcutElements[1], "ally", "");
|
||||
@@ -111,10 +72,6 @@ if (layCastleTopElements.length == 1) {
|
||||
shortcutElementReplace(shortcutElements[5], "tools", "");
|
||||
shortcutElementReplace(shortcutElements[6], "favorites", "");
|
||||
|
||||
shortcutBar = layCastleTopElements[0].getElementsByClassName("shortcut-element")[0];
|
||||
shortcutElementAddFlag(shortcutBar, "left");
|
||||
shortcutElementAddFlag(shortcutBar, "right");
|
||||
|
||||
shortcutContainers = layCastleTopElements[0].getElementsByClassName("shortcut_container");
|
||||
shortcutContainers[0].classList.add("shortcut_container_left");
|
||||
shortcutContainers[2].classList.add("shortcut_container_right");
|
||||
|
||||
Reference in New Issue
Block a user