Last active
October 11, 2024 18:28
-
-
Save jaysethi7287/91f6068f987093032a09dd187b84ae40 to your computer and use it in GitHub Desktop.
Seat Booking Deletion Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For OCTOBER | |
function getElementByXPath(xpath) { | |
return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
} | |
const initialButtonXPath = '/html/body/div[1]/div[2]/div[2]/div[3]/button[1]'; | |
const initialButton = getElementByXPath(initialButtonXPath); | |
if (initialButton) { | |
initialButton.click(); | |
console.log('Initial button clicked.'); | |
// click the button at /html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[1]/div[2]/button[2] after 500ms, then click it again after 500 ms | |
// const nextButtonXPath = '/html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[1]/div[2]/button[2]'; | |
setTimeout(() => { | |
const containerXPath = '/html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[4]/div[2]/div'; | |
const targetDiv = getElementByXPath(containerXPath); | |
if (targetDiv) { | |
const targetDivButton = targetDiv.querySelector('button'); | |
if (targetDivButton) { | |
targetDivButton.click(); | |
console.log('Button clicked in target div.'); | |
setTimeout(() => { | |
const firstButtonXPath = '/html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[2]/div[1]/div[2]/div[1]/button'; | |
const firstButton = getElementByXPath(firstButtonXPath); | |
if (firstButton) { | |
firstButton.click(); | |
console.log('First additional button clicked.'); | |
setTimeout(() => { | |
const secondButtonXPath = '/html/body/div[1]/div[3]/div[2]/div/div[2]/button[1]'; | |
const secondButton = getElementByXPath(secondButtonXPath); | |
if (secondButton) { | |
secondButton.click(); | |
console.log('Second additional button clicked.'); | |
} else { | |
console.error('Second additional button not found.'); | |
} | |
}, 1000); // Second delay | |
} else { | |
console.error('First additional button not found.'); | |
} | |
}, 1000); // First delay | |
} else { | |
console.error('Button not found in the target div.'); | |
} | |
} else { | |
console.error('Target div not found with the specified XPath.'); | |
} | |
}, 500); | |
} else { | |
console.error('Initial button not found.'); | |
} | |
// ---------------------------------------------------------------------------------------------------------------- | |
// FOR NOVEMBER | |
function getElementByXPath(xpath) { | |
return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
} | |
const initialButtonXPath = '/html/body/div[1]/div[2]/div[2]/div[3]/button[1]'; | |
const initialButton = getElementByXPath(initialButtonXPath); | |
if (initialButton) { | |
initialButton.click(); | |
console.log('Initial button clicked.'); | |
// click the button at /html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[1]/div[2]/button[2] after 500ms, then click it again after 500 ms | |
const nextButtonXPath = '/html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[1]/div[2]/button[2]'; | |
setTimeout(() => { | |
const nextButton = getElementByXPath(nextButtonXPath); | |
if (nextButton) { | |
nextButton.click(); | |
console.log('Next button clicked.'); | |
} else { | |
console.error('Next button not found.'); | |
} | |
}, 500); | |
setTimeout(() => { | |
const containerXPath = '/html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[4]/div[2]/div'; | |
const targetDiv = getElementByXPath(containerXPath); | |
if (targetDiv) { | |
const targetDivButton = targetDiv.querySelector('button'); | |
if (targetDivButton) { | |
targetDivButton.click(); | |
console.log('Button clicked in target div.'); | |
setTimeout(() => { | |
const firstButtonXPath = '/html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[2]/div[1]/div[2]/div[1]/button'; | |
const firstButton = getElementByXPath(firstButtonXPath); | |
if (firstButton) { | |
firstButton.click(); | |
console.log('First additional button clicked.'); | |
setTimeout(() => { | |
const secondButtonXPath = '/html/body/div[1]/div[3]/div[2]/div/div[2]/button[1]'; | |
const secondButton = getElementByXPath(secondButtonXPath); | |
if (secondButton) { | |
secondButton.click(); | |
console.log('Second additional button clicked.'); | |
} else { | |
console.error('Second additional button not found.'); | |
} | |
}, 1000); // Second delay | |
} else { | |
console.error('First additional button not found.'); | |
} | |
}, 1000); // First delay | |
} else { | |
console.error('Button not found in the target div.'); | |
} | |
} else { | |
console.error('Target div not found with the specified XPath.'); | |
} | |
}, 500); | |
} else { | |
console.error('Initial button not found.'); | |
} | |
// ---------------------------------------------------------------------------------------------------------------- | |
// FOR DECEMBER | |
function getElementByXPath(xpath) { | |
return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
} | |
const initialButtonXPath = '/html/body/div[1]/div[2]/div[2]/div[3]/button[1]'; | |
const initialButton = getElementByXPath(initialButtonXPath); | |
if (initialButton) { | |
initialButton.click(); | |
console.log('Initial button clicked.'); | |
// click the button at /html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[1]/div[2]/button[2] after 500ms, then click it again after 500 ms | |
const nextButtonXPath = '/html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[1]/div[2]/button[2]'; | |
setTimeout(() => { | |
const nextButton = getElementByXPath(nextButtonXPath); | |
if (nextButton) { | |
nextButton.click(); | |
console.log('Next button clicked.'); | |
setTimeout(() => { | |
nextButton.click(); | |
console.log('Next button clicked again.'); | |
}, 500); | |
} else { | |
console.error('Next button not found.'); | |
} | |
}, 500); | |
setTimeout(() => { | |
const containerXPath = '/html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[4]/div[2]/div'; | |
const targetDiv = getElementByXPath(containerXPath); | |
if (targetDiv) { | |
const targetDivButton = targetDiv.querySelector('button'); | |
if (targetDivButton) { | |
targetDivButton.click(); | |
console.log('Button clicked in target div.'); | |
setTimeout(() => { | |
const firstButtonXPath = '/html/body/div[1]/div[2]/div[3]/div[2]/div/div/div[2]/div[1]/div[2]/div[1]/button'; | |
const firstButton = getElementByXPath(firstButtonXPath); | |
if (firstButton) { | |
firstButton.click(); | |
console.log('First additional button clicked.'); | |
setTimeout(() => { | |
const secondButtonXPath = '/html/body/div[1]/div[3]/div[2]/div/div[2]/button[1]'; | |
const secondButton = getElementByXPath(secondButtonXPath); | |
if (secondButton) { | |
secondButton.click(); | |
console.log('Second additional button clicked.'); | |
} else { | |
console.error('Second additional button not found.'); | |
} | |
}, 1000); // Second delay | |
} else { | |
console.error('First additional button not found.'); | |
} | |
}, 1000); // First delay | |
} else { | |
console.error('Button not found in the target div.'); | |
} | |
} else { | |
console.error('Target div not found with the specified XPath.'); | |
} | |
}, 500); | |
} else { | |
console.error('Initial button not found.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Steps:
a. You have to paste + enter for every deletion - Engage will warn you if you for loop across all entries that are to be deleted
b. If for whatever reason it errors out, run it again (sometimes the divs do not load in time, so it requires loading it first and running it
after)