Skip to content

Commit

Permalink
fix: break early during challenge reset
Browse files Browse the repository at this point in the history
  • Loading branch information
dessant committed Feb 21, 2019
1 parent 73bc76e commit baa6581
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/content/reset.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
(function() {
const onMessage = function(e) {
e.stopImmediatePropagation();
window.clearTimeout(timeoutId);

const challengeUrl = e.detail;
const reset = function(challengeUrl) {
for (const [k, client] of Object.entries(___grecaptcha_cfg.clients)) {
for (const [_, items] of Object.entries(client)) {
for (const [_, v] of Object.entries(items)) {
if (v instanceof Element && v.src === challengeUrl) {
grecaptcha.reset(k);
break;
return;
}
}
}
}
};

const onMessage = function(e) {
e.stopImmediatePropagation();
window.clearTimeout(timeoutId);

reset(e.detail);
};

const timeoutId = window.setTimeout(function() {
document.removeEventListener('___resetCaptcha', onMessage, {
capture: true,
Expand Down

0 comments on commit baa6581

Please sign in to comment.