Skip to content

Instantly share code, notes, and snippets.

@jaysethi7287
Last active October 11, 2024 18:28
Show Gist options
  • Save jaysethi7287/91f6068f987093032a09dd187b84ae40 to your computer and use it in GitHub Desktop.
Save jaysethi7287/91f6068f987093032a09dd187b84ae40 to your computer and use it in GitHub Desktop.
Seat Booking Deletion Script
// 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.');
}
@jaysethi7287
Copy link
Author

jaysethi7287 commented Oct 11, 2024

Steps:

  1. Open Engage, login, and go to book a space
  2. Open your browser's console - Option + ⌘ + J (on macOS), or Shift + CTRL + J (on Windows/Linux)
  3. Paste the October/November/December script to delete from the respective months
    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)
  4. Let me know if you need any help - [email protected]/Jayaditya Sethi on slack

@jaysethi7287
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment