The content in the custom block plugin is probably sanitized and the script part is of course the problem there. See Differentiation of HTML-capable text blocks
I guess one way would be to allow the use of script tag, but that is not a good idea. The other option is to write a small block plugin for the google search. It is not a big job, if you take some existing block plugin as the starting point.