Add calculator button in ally attacks
This commit is contained in:
@@ -31,6 +31,14 @@ function createRow(key, value) {
|
||||
return row;
|
||||
}
|
||||
|
||||
function createInput(type, name, value) {
|
||||
let elt = document.createElement("input");
|
||||
elt.setAttribute("type", type);
|
||||
elt.setAttribute("name", name);
|
||||
elt.setAttribute("value", value);
|
||||
return elt;
|
||||
}
|
||||
|
||||
function shortcutElementReplace(elt, img, text) {
|
||||
// If more than one hyperlink element found,
|
||||
// then keep the last one but with href of the first one.
|
||||
@@ -208,6 +216,9 @@ function main() {
|
||||
let table = contentPane.getElementsByClassName("borderlist")[0];
|
||||
let rows = table.getElementsByTagName("tr");
|
||||
|
||||
let headCell = document.createElement("th");
|
||||
rows[0].appendChild(headCell);
|
||||
|
||||
for (let i = 1; i < rows.length; i ++) {
|
||||
let cells = rows[i].getElementsByTagName("td");
|
||||
let arrivalDateCell = cells[3]
|
||||
@@ -218,6 +229,26 @@ function main() {
|
||||
let arrival = new Date(Date.now() + seconds * 1000);
|
||||
let hour = arrival.toLocaleTimeString("fr-FR");
|
||||
arrivalDateCell.textContent = arrivalDateCell.textContent.replace(/(.*)\d\d:\d\d(.*)/, "$1" + hour + "$2");
|
||||
|
||||
let startPoint = cells[2].getElementsByTagName("a")[3].textContent.split("|");
|
||||
let targetPoint = cells[1].getElementsByTagName("a")[2].textContent.split("|");
|
||||
let calculatorCell = document.createElement("td");
|
||||
let calculatorForm = document.createElement("form");
|
||||
calculatorForm.setAttribute("method", "post");
|
||||
calculatorForm.setAttribute("action", "/?s=tools&m=runtime_calculator&inta=calculate");
|
||||
calculatorForm.appendChild(createInput("hidden", "start_x", startPoint[0]));
|
||||
calculatorForm.appendChild(createInput("hidden", "start_y", startPoint[1]));
|
||||
calculatorForm.appendChild(createInput("hidden", "target_x", targetPoint[0]));
|
||||
calculatorForm.appendChild(createInput("hidden", "target_y", targetPoint[1]));
|
||||
let calculatorImg = document.createElement("input");
|
||||
calculatorImg.setAttribute("type", "image");
|
||||
calculatorImg.setAttribute("src", chrome.runtime.getURL("images/calculator.svg"));
|
||||
calculatorImg.style.width = "20px";
|
||||
calculatorImg.style.height = "20px";
|
||||
calculatorImg.style.border = "none";
|
||||
calculatorForm.appendChild(calculatorImg);
|
||||
calculatorCell.appendChild(calculatorForm);
|
||||
rows[i].appendChild(calculatorCell);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user