Skip to content

Instantly share code, notes, and snippets.

@ahmedrowaihi
Created August 17, 2023 09:56
Show Gist options
  • Save ahmedrowaihi/6d8b4c1c7958bdbd619cdc28ae1e0c8c to your computer and use it in GitHub Desktop.
Save ahmedrowaihi/6d8b4c1c7958bdbd619cdc28ae1e0c8c to your computer and use it in GitHub Desktop.
This small code snippet is to fill out the survey form | تخطي الاستبيان
// Github: ahmedrowaihi
// HOW TO USE:
// OPEN THE browser console
// Press [CTRL + SHIFT + I]
// THEN COPY PASTE THE CODE BELLOW TO THE CONSOLE AND HIT [ENTER]
const elements = Array.from(document.all).filter(element => element.id.endsWith('rbAnswer'));
elements.forEach(element => {
const radioButtons = element.querySelectorAll('input[type="radio"]');
let targetRadioButton;
if (radioButtons.length === 2) {
targetRadioButton = radioButtons[1];
} else {
const middleIndex = Math.floor(radioButtons.length / 2);
targetRadioButton = radioButtons[middleIndex];
}
targetRadioButton.click();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment