miguelshta
Member
hello this is not tibia related but i want help from here i really know very good programes here only
so ill explain my objetive
in here i need to click an button "Eliminar" to delete lines one by one because i need to keep some lines in specific im trying to do a javascript for tampermonkey; if you know a better solution for this like c++ or lua please tell me here
this is my script it wont work i really didnt know why but in advance if you can help me with anything i said thank you!
so ill explain my objetive
in here i need to click an button "Eliminar" to delete lines one by one because i need to keep some lines in specific im trying to do a javascript for tampermonkey; if you know a better solution for this like c++ or lua please tell me here
JavaScript:
let delete_nums = ["#SO202771", "#SO202772", "#SO202773"];
function getRowsToDelete() {
// Initialize an array that's going to contain all the rows to be deleted
let delete_rows = [];
// Get the element that contains all the rows
const ordenDeVenta = document.getElementsByClassName("uir-machine-row");
// Loop through all these rows
Array.from(ordenDeVenta).forEach(row => {
// Find the cell that contains the order no.
const cellWithNum = row.children[x];
// Go through each order no that has to be deleted
delete_nums.forEach(num => {
// If it's in the cell
if (cellWithNum.textContent.contains(num)) {
// Add the row to the array
delete_rows.push(row);
}
})
})
// Return the array with rows to be deleted
return delete_rows;
}
// Now you have all the rows here that have to be deleted
let rows = getRowsToDelete();
function deleteRow(row) {
// Click the row
row.click();
// Set an interval to wait for the button to show
const wait = setInterval(() => {
const btn = row.getElementsByClassName("Eliminar");
if (btn) {
clearInterval(wait);
btn[0].click();
// Remove the first item of the array
rows.shift();
// If there are more left
if (rows.length) {
// Repeat
deleteRow(rows[0]);
}
}
}, 250);
}
deleteRow(rows[0]);