Skip to content

Instantly share code, notes, and snippets.

@Caedilla
Created February 28, 2023 19:04
Show Gist options
  • Save Caedilla/94faf8dc328ed27c86e5585e28cf4485 to your computer and use it in GitHub Desktop.
Save Caedilla/94faf8dc328ed27c86e5585e28cf4485 to your computer and use it in GitHub Desktop.
Find a good phone number. Searches page for a number with repeating digits, and then searches the rest of the value for more repeating digits.
const firstRepeating = /(\d)\1{1,2}/;
const checkRepeating = /(\d)\1{1,2}/;
const selectElements = document.getElementsByTagName('select');
let matchingValues = '';
for (const selectElement of selectElements) {
const matchingOptions = selectElement.getElementsByTagName('option');
for (const option of matchingOptions) {
const value = option.value;
const index = value.search(firstRepeating);
if (index !== -1) {
const remaining = value.substring(index + 1);
if (checkRepeating.test(remaining)) {
matchingValues += `"${value}"\n`;
}
}
}
}
if (matchingValues) {
alert(`Matching values found:\n${matchingValues}`);
} else {
setInterval(() => {
location.reload();
}, 500);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment