I'm wondering if you can have Greasemonkey execute against an iframe only and not it's parent window. The parent window is domain A, the iframe is domain B, and the include in the script would be @include http://domain-B.com/path/*.
I don't need any interaction with the parent. I've tried this a couple of times without success. Is there any cross-domain restriction preventing someone to execute against the iframe?
PS: The iframe has JS code that prevents it from loading as the top window.
Well, it's certainly possible to get Greasemonkey to run against an iframe -- in fact, it's a common question to determine how to stop it from executing on iframes as well as the main page. You should be able to take the converse of that answer to prevent code from executing on the top window:
I've tested it and you can use
@include
to match domain B (the domain of theiframe
) and run a piece of arbitrary code that modifies it. I ran the following test userscript on a test page and it successfully hides the Google logo (only when Google is in aniframe
).So far as I can tell, there aren't any cross-domain restrictions involved here. I'm not sure what happens if the
iframe
isn't present when the page is first loaded (which is when Greasemonkey runs).