Use Mutation Observers to observe captcha changes instead of Mutation Listeners when possible.
This commit is contained in:
parent
43530b0302
commit
1246df80af
@ -6276,7 +6276,7 @@
|
|||||||
}), this.ready.bind(this));
|
}), this.ready.bind(this));
|
||||||
},
|
},
|
||||||
ready: function() {
|
ready: function() {
|
||||||
var imgContainer, inputContainer;
|
var MutationObserver, imgContainer, inputContainer, observer;
|
||||||
imgContainer = $.el('div', {
|
imgContainer = $.el('div', {
|
||||||
className: 'captchaimg',
|
className: 'captchaimg',
|
||||||
title: 'Reload',
|
title: 'Reload',
|
||||||
@ -6293,9 +6293,16 @@
|
|||||||
img: imgContainer.firstChild,
|
img: imgContainer.firstChild,
|
||||||
input: inputContainer.firstChild
|
input: inputContainer.firstChild
|
||||||
};
|
};
|
||||||
|
if (MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.OMutationObserver) {
|
||||||
|
observer = new MutationObserver(this.load.bind(this));
|
||||||
|
observer.observe(this.nodes.challenge, {
|
||||||
|
childList: true
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$.on(this.nodes.challenge, 'DOMNodeInserted', this.load.bind(this));
|
||||||
|
}
|
||||||
$.on(imgContainer, 'click', this.reload.bind(this));
|
$.on(imgContainer, 'click', this.reload.bind(this));
|
||||||
$.on(this.nodes.input, 'keydown', this.keydown.bind(this));
|
$.on(this.nodes.input, 'keydown', this.keydown.bind(this));
|
||||||
$.on(this.nodes.challenge, 'DOMNodeInserted', this.load.bind(this));
|
|
||||||
$.sync('captchas', this.count.bind(this));
|
$.sync('captchas', this.count.bind(this));
|
||||||
this.count($.get('captchas', []));
|
this.count($.get('captchas', []));
|
||||||
this.reload();
|
this.reload();
|
||||||
|
|||||||
@ -522,9 +522,15 @@ QR =
|
|||||||
img: imgContainer.firstChild
|
img: imgContainer.firstChild
|
||||||
input: inputContainer.firstChild
|
input: inputContainer.firstChild
|
||||||
|
|
||||||
$.on imgContainer, 'click', @reload.bind @
|
if MutationObserver = window.MutationObserver or window.WebKitMutationObserver or window.OMutationObserver
|
||||||
$.on @nodes.input, 'keydown', @keydown.bind @
|
observer = new MutationObserver @load.bind @
|
||||||
$.on @nodes.challenge, 'DOMNodeInserted', @load.bind @
|
observer.observe @nodes.challenge,
|
||||||
|
childList: true
|
||||||
|
else
|
||||||
|
$.on @nodes.challenge, 'DOMNodeInserted', @load.bind @
|
||||||
|
|
||||||
|
$.on imgContainer, 'click', @reload.bind @
|
||||||
|
$.on @nodes.input, 'keydown', @keydown.bind @
|
||||||
$.sync 'captchas', @count.bind @
|
$.sync 'captchas', @count.bind @
|
||||||
@count $.get 'captchas', []
|
@count $.get 'captchas', []
|
||||||
# start with an uncached captcha
|
# start with an uncached captcha
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user