У меня есть скрипт для проверки появления капчи, но функции стрелки не работают в 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'] })
}
Две строки проблематичны:
.find(x=>x.src.includes('google.com/recaptcha/api2/bframe'))
.parentNode.parentNode
и:
new MutationObserver(x => recaptchaWindow.style.opacity == 0 && onClose())
Как мне провести рефакторинг этих двух строк?