The title is pretty much the question:
Is it possible to add a Greasemonkey script to an iframed website?
If so, how?
Thank you.
The title is pretty much the question:
Is it possible to add a Greasemonkey script to an iframed website?
If so, how?
Thank you.
Note that if you're making a chrome extension for your userscript, you also need to add
"all_frames": true
to your manifest or your extension won't work on iframes.Example:
In Greasemonkey (And Tampermonkey and most userscript engines) a script will fire on an iframe automatically if it meets the @include, @exclude, and/or @match directives.
And, a popular question is how to stop Greasemonkey from firing on iframes.
So, if your script had a match like:
It would fire on jsFiddle "output" pages whether or not they appeared in an iframe.
If you wanted to fire on a JUST iframed content:
Then you would check the
window.self
property.For example, suppose you had a target page like:
Then you could use a script like:
Important:
With the release of Greasemonkey 4, iframes handling is severely crippled (and many other things are broken, besides).
It still works properly with Tampermonkey, Violentmonkey and just about every other userscript engine.
It is strongly recommended (including by Greasemonkey itself) that you do not use Greasemonkey 4 or later.