TL;DR version: You can't modify iframes at all, but you can render a modified site in a div.
Okay, so you can't modify an iframe at all, but you can render a site in a div. It's a really hacky solution, but it gets the job done (I won't be posting a solution in code, but instead tell you how to do it)
To begin with, replace your iframe element with a div. This div will contain the modified site.
You'll then need to get the contents of Google's site. Because JavaScript can be temperamental at times with permissions, I'll suggest two solutions to get the content of a site.
Use PHP to get the contents of a site. It's even easier to modify it in PHP too! Then you can just make an AJAX request to the PHP file and get the modified content.
Using JavaScript solely, you can get the content of an URL using AJAX. Check out this topic
Now, since you want to modify some HTML, you'll have to do a recursive search throughout the content for any tags, and then replace them. Bear in mind that if you sloppily search through it, you'll end up with a half-working filter.
I'm assuming Google references files locally, e.g logo.png
, rather than http://www.google.com/logo.png
. This means that when it is finally rendered, you'll end up with broken file references everywhere and a site that looks nothing like google. To fix this, search through the content with a filter only for file references and URLs. Check if the URL is logo, you can do this by checking if the URL contains http:// or https://
. If it doesn't contain this, add http://www.google.com
as a prefix to the URL. This should cause all references to be fixed.
Finally, to render the content, just add it to the "iframe" div. You should give the div a width and height to make it seem more like an iframe.
I hoped this helped ;)