Thank you so much!

That worked perfectly, I cannot believe I did not come across this in
all my searching for a solution.

I suppose I did learn a fair bit about browsers & greasemonkeys
methods of security.

And cheers for the tips using GM_get & GM_set.



For anyone else that stumbles across this thread, heres how I made the
script run on the different frames:

@include both urls

if(document.location.href.indexOf("URL1"))
{
GM_setValue("createdInUrl1", true);

//Code for url 1
}

else if(document.location.href.indexOf("URL2") != -1 &&
GM_getValue("createdInUrl1"))
{
GM_setValue("createdInUrl1", false);

//Code for url 2, i.e. the iframe.
}


Because the browser will block communication between different
domains, parent.etc will not work nor will window.top.etc. So as
suggested above I used GM get/set value.
Setting it to false in the iframe branch ensures it is not set if the
user visits just the iframe url on its own.



On Jul 28, 1:21 am, AClone Iam <[email protected]> wrote:
> 1) Include the domain of the iframe in the scripts includes
> 2) the script will now run once for the normal window and again for the
> iframe content.  You will need to detect which domain the script is running
> in, and action accordingly.
>
> You can exchange data between the two running instances of your script, by
> either using
> a) GM_set and GM_get, or
> b) messaging.
>
> Das Shrubber
>
> On Tue, Jul 27, 2010 at 7:59 AM, Tim <[email protected]> wrote:
> > Hi there,
>
> > I've written a greasemonkey script that creates an 'iframe', and sets
> > it source to a different domain of the original webpage. This works
> > fine.
>
> > How do I access elements in this iframe? Specifically how do I
> > use .getElementById("")?
>
> > The actual element itself is defined (in a XPCNativeWrapper) and
> > its .body etc, but I cannot use .getElementById or tagName.
>
> > I've tried:
> > var frameDoc =
> > document.wrappedJSObject.getElementById("frameID").contentDocument;
> > GM_log( frameDoc.getElementById("idname") );
>
> > And without the wrappedJSObject. Both cases return 'null' or
> > 'undefined'.
>
> > I've tried setting timeout manually with: window.setTimeout(test,
> > 3000);
> > Where test was a function holding the above.
>
> > And I've tried a timer with
> > frameDoc.addEventListener("DOMFrameContentLoaded", test, false);
>
> > With the timers I got errors either: "Security Manager vetoed
> > action...." if used without unwrapping first with wrappedJSObject, or
> > "permission denied.... site xyz to load html.document from site 123".
>
> > Any help would be greatly appreciated!
>
> > I may consider using GM_XmlHttpRequest instead, however this would not
> > work on chrome.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "greasemonkey-users" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<greasemonkey-users%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/greasemonkey-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to