WP-reCAPTCHA: javascript error in pages without submit button

[UPDATE]: it seems that the problemis solved since version 3.1.5 (but I’m not certain if this is version 3.1.5 or since 3.1.6. Anyway, you don’t need to read this post if you are using one of those versions or above.

Motivation: I’m using the WP-reCAPTCHA plugin and there is a javascript error in every page where I didn’t include any post comment box.
Solution: Found here. But I’m copying the solution here anyway:
“In the recaptcha.php page, there’s a function called “save_comment_script”. In the middle of it is a block of code that currently looks like this”

<script type="text/javascript">
var sub = document.getElementById('submit');
document.getElementById('recaptcha-submit-btn-area').appendChild (sub);
document.getElementById('submit').tabIndex = 6;
if ( typeof _recaptcha_wordpress_savedcomment != 'undefined') {
	document.getElementById('comment').value = _recaptcha_wordpress_savedcomment;
}
document.getElementById('recaptcha_table').style.direction = 'ltr';
</script>

Change that code to look like this:

<script type="text/javascript">
if(document.getElementById('submit') != null)
{
	var sub = document.getElementById('submit');
	document.getElementById('recaptcha-submit-btn-area').appendChild (sub);
	document.getElementById('submit').tabIndex = 6;
	if ( typeof _recaptcha_wordpress_savedcomment != 'undefined') {
		document.getElementById('comment').value = _recaptcha_wordpress_savedcomment;
	}
	document.getElementById('recaptcha_table').style.direction = 'ltr';
}
</script>

Code Snippet

Note: this post is deprecated, I moved to another plugin, see this new post.

Motivation: I want to publish code into my posts. I’m not really motivated to search or code anything so I’ll go for a plugin this time.

Solution: I found this plugin called “WordPress Code Snippet” which for me it’s okay. Maybe in the future I’ll search for another solution but right now it does the trick.