On a page I\'m doing I will be ending up with custom link elements like this:
I know this is 7 years old, but this is how you do it (for attribute values):
function DOMRegex(regex) {
let output = [];
for (let i of document.querySelectorAll('*')) {
if (regex.test(i.type)) { // or whatever attribute you want to search
output.push(i);
}
}
return output;
}
console.log(DOMRegex(/^service\//)); // your regex here
To search all element attributes, you can use this:
function DOMRegex(regex) {
let output = [];
for (let i of document.querySelectorAll('*')) {
for (let j of i.attributes) {
if (regex.test(j.value)) {
output.push({
'element': i,
'attribute name': j.name,
'attribute value': j.value
});
}
}
}
return output;
}
console.log(DOMRegex(/(?
I put it in a nice object layout for you.