Last active
December 19, 2017 09:39
-
-
Save oberhamsi/068a6b00e25f89b98ca027241ca0c918 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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