Skip to content

Instantly share code, notes, and snippets.

@oberhamsi
Last active December 19, 2017 09:39
Show Gist options
  • Save oberhamsi/068a6b00e25f89b98ca027241ca0c918 to your computer and use it in GitHub Desktop.
Save oberhamsi/068a6b00e25f89b98ca027241ca0c918 to your computer and use it in GitHub Desktop.
function recurseIframes(doc, iframes) {
let newIframes = doc.querySelectorAll('iframe');
if (newIframes.length > 0) {
iframes.push.apply(iframes, newIframes);
newIframes.forEach(iframe => {
recurseIframes(iframe, iframes);
})
}
return iframes;
}
recurseIframes(document, []).forEach(iframe => {
let formElements = document.querySelectorAll("[type='submit'], form, input, textarea");
if (formElements.length > 0) {
console.log(`iFrame with form elements has src ${iframe.src}`);
console.log('form elements are:', formElements);
let owner = iframe;
while (owner = owner.ownerDocument) {
console.log(`ownerDocument src: ${iframe.ownerDocument.src}`);
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment