I have a script to check for the appearance of a captcha, but are arrow functions break down on IE.
function initListener() {
// set a global to tell that we are listening
window.recaptchaCloseListener = true
// find the open reCaptcha window
HTMLCollection.prototype.find = Array.prototype.find
var recaptchaWindow = document
.getElementsByTagName('iframe')
.find(x=>x.src.includes('google.com/recaptcha/api2/bframe'))
.parentNode.parentNode
// and now we are listening on CSS changes on it
// when the opacity has been changed to 0 we know that
// the window has been closed
new MutationObserver(x => recaptchaWindow.style.opacity == 0 && onClose())
.observe(recaptchaWindow, { attributes: true, attributeFilter: ['style'] })
}
Two lines are problematic:
.find(x=>x.src.includes('google.com/recaptcha/api2/bframe'))
.parentNode.parentNode
and:
new MutationObserver(x => recaptchaWindow.style.opacity == 0 && onClose())
How do I refactor these two lines?