0
I’m doing some tests using Google Recaptcha.
What I am trying to do is to automatically click on the checkbox when the captcha appears. I took this function teste()
on the website of greasemonkey
and it works perfectly using the plugin, but it doesn’t work if I add it directly to my page.
Could anyone tell me why? What greasemonkey
makes it different for the script work?
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type='text/javascript' src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body onload='test();'>
<form action="hello" method="POST">
<div id='testid'>
<div class="g-recaptcha"
data-sitekey="SITE_KEY_HERE"
data-callback="onSuccess">
</div>
</div>
</form>
</body>
<script>
function test() {
var domain = (window.location != window.parent.location) ? document.referrer.toString() : document.location.toString();
if (domain.indexOf('miped.ru') == -1 && domain.indexOf('indiegala') == -1 && domain.indexOf('gleam.io') == -1) {
var clickCheck = setInterval(function() {
console.log('test');
if (document.querySelectorAll('.recaptcha-checkbox-checkmark').length > 0) {
clearInterval(clickCheck);
document.querySelector('.recaptcha-checkbox-checkmark').click();
}
}, 100);
}
}
var onSuccess = function(response) {
alert(grecaptcha.getResponse());
};
</script>
</html>
Hmm, interesting. And how can he inject if the domains are different?
– Felpsaps
Which domains? If possible, link to the original
greasemonkey
.– Valdeir Psr
No, I mean, the iframe domain is Google domain. Can’t change an iframe when it has another domain than my correct website? The original greasemonkey post is: https://greasyfork.org/pt-BR/scripts/18449-recaptcha-helper/code
– Felpsaps
When the browser requests the script
greasemonkey
detects the return and uses the browser itself to inject this code. When you try to change the iframe on your html page, it is the browser that blocks this action. You can also make these insertions with the use of Extensions for Chrome or Webextensions for Firefox– Valdeir Psr
Ahh, so there’s no way I can do the same, inject this script, through my page?
– Felpsaps
No. No way. Only using extensions for browsers.
– Valdeir Psr
What a bag But thank you, it was very enlightening!
– Felpsaps