我有一个脚本来检查验证码的外观,但是箭头功能在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())
如何重构这两行?
答案 0 :(得分:0)
此解决方案需要.include()和Array.from()的polyfill,如下所示:
Array.from on the Internet Explorer
ie does not support 'includes' method
以及更新的代码:
function initListener(){
<button class="._3S2w"><i class="._2UFd" /></button>