-
Notifications
You must be signed in to change notification settings - Fork 0
/
google_recaptcha.v3.js
111 lines (82 loc) · 2.92 KB
/
google_recaptcha.v3.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/** @var {Array} captchaTargetActList */
/** @var {String} gCaptchaPending */
grecaptcha.ready(function () {
grecaptcha.execute(gCaptchaSiteKey, {action: 'homepage'}).then(function (token) {
googleReCaptchaV3.verify(token);
});
});
var googleReCaptchaV3 = {
ready: false,
hookedDelegateArgs: null,
$html: null,
$typeSelector: null,
bindAllForm: function () {
$('form').each(function () {
var $forms = $(this);
$forms.each(function () {
var $form = $(this);
if ($form.hasOnSubmitAndOnProcFilter($form)) {
if ($form.isRequrieSubmitHook($form)) {
$form.submit(googleReCaptchaV3.submitEvent);
}
}
});
});
},
submitEvent: function (e) {
e.preventDefault();
alert('지원안함');
return false;
},
exec_xml: function (module, act, params, delegate, responseTags, delegateArgs, formObject) {
if (!googleReCaptchaV3.ready) {
alert(gCaptchaPending);
return false;
}
params.google_response = googleReCaptchaV3.token;
window.oldExecXml(module, act, params, delegate, responseTags, delegateArgs, formObject);
return true;
},
verify: function (token) {
googleReCaptchaV3.bindAllForm();
googleReCaptchaV3.ready = true;
googleReCaptchaV3.token = token;
},
submit: function () {
var args = googleReCaptchaV3.hookedDelegateArgs;
window.oldExecXml(args.module, args.act, args.params, args.callback_func, args.response_tags, args.callback_func_arg, args.fo_obj);
googleReCaptchaV3.hookedDelegateArgs = null;
}
};
if (typeof (jQuery) == "undefined") {
alert('Error: This document does not include jQuery.');
}
jQuery(function ($) {
jQuery.fn.extend({
hasOnSubmitAndOnProcFilter: function () {
if (this.length > 1)
throw "Only one element can be selected.";
var $f = $(this);
return !$f.attr('onsubmit') || $f.attr('onsubmit').indexOf('procFilter') < 0;
},
isRequrieSubmitHook: function () {
if (this.length > 1)
throw "Only one element can be selected.";
var $f = $(this);
var act = $f.find('input[name=act]').val();
var onsubmit = $f.attr('onsubmit');
for (var k in captchaTargetActList) {
var captchaTargetAct = captchaTargetActList[k];
if ((!onsubmit || onsubmit.indexOf(captchaTargetAct) < 0) && act.length > 0) {
return captchaTargetAct == act;
}
}
return false;
}
});
captchaTargetActList.push("IS");
if (!window.oldExecXml) {
window.oldExecXml = window.exec_xml;
window.exec_xml = googleReCaptchaV3.exec_xml;
}
});