I'm trying to write a little Greasemonkey script (in Firefox) to manipulate the top bar Google Translate produces when translating a site. For example: http://translate.google.com/translat.../www.google.de
Google has employed traditional HTML frames. According to many websites, I can use something like window.frames.contentDocument to access the first frame. However, this is refusing to work!
I have been debugging this for hours. I have verified that I am indeed running the script from the top-level window (window.parent === window.top), and I am able to manipulate the frames themselves without a problem. When I try something like window.frames.contentDocument.URL, it returns as about
:blank (I also get this with the other frame, i.e., frames). I have tried several different methods of getting at that frame, including getElementsByTagName("frame") (which works for manipulating the frame itself, but not for editing the frame's content through contentDocument).
Here's my little script so far. I've included the first part so you can see for yourself that I'm definitely in the top-level window and using the right @include because it works. In this example, the URL returned is "about
:blank" (again, I'm in Firefox).
// @name GTranslate
// @include /^https?://translate\.google\.com/translate\?.*/
// change how the frame is displayed
var bar = document.getElementsByTagName("frame");
// manipulate the content inside the frame
var gt = bar.contentDocument;