Skip to content

Instantly share code, notes, and snippets.

@chavesm
Last active March 16, 2021 14:53
Show Gist options
  • Save chavesm/46c6f6db7f1aab0e2dbbfad04b7630cf to your computer and use it in GitHub Desktop.
Save chavesm/46c6f6db7f1aab0e2dbbfad04b7630cf to your computer and use it in GitHub Desktop.
Find Links and Forms Using JavaScript and Chrome Dev Tools (snippets and console)
console.clear();
let allForms = [];
let problems = [];
$$("form").forEach((f) => {
allForms.push(f);
if (!f.hasAttribute("id")) {
f.style.border = "3px solid orangered";
problems.push(f);
} else {
f.style.border = "3px solid limegreen";
}
});
if (allForms.length > 0) {
console.info('There are %d forms.', allForms.length);
console.groupCollapsed('All forms');
allForms.forEach(f => {console.dirxml(f)});
console.groupEnd('All forms');
}
if (problems.length > 0) {
console.warn('%cThere were %d forms with no ID.', 'color: orangered', problems.length);
console.groupCollapsed('Forms without ID');
problems.forEach(f => {console.dirxml(f)});
console.groupEnd('Forms without ID');
}
console.clear();
let problems = [];
$$("form").forEach((f) => {
if (!f.hasAttribute("id")) {
f.style.border = "3px solid orangered";
problems.push(f);
}
});
if (problems.length > 0) {
console.warn('%cThere were %d forms with no ID.', 'color: orangered', problems.length);
console.groupCollapsed('Forms without ID');
problems.forEach(f => {console.dirxml(f)});
console.groupEnd('Forms without ID');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment