• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

PHP java script help auto click on button

miguelshta

Member
Joined
Mar 21, 2009
Messages
351
Solutions
1
Reaction score
13
Location
Toronto, Canada
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
Animation.gif


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]);
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!
 
Back
Top