Reputation: 279
I'm trying to prevent my Greasemonkey script from executing within IFRAMEs. I'm doing so by using if (window.top != window.self) return;
. As soon as I insert that line right after the metadata header, the error console throws out a "Security Manager vetoed action" indicating this exact line of code. There's no additional information available.
I'm using Firefox 3.6.10 and the latest Greasemonkey extension. Oh, I'm new to user scripts but even after some time looking for an answer I didn't find anything at all.
Upvotes: 1
Views: 1680
Reputation: 66415
Greasemonkey has an own API, which allows persistent storage and cross-site HTTP requests. For this reason, scripts are executed in a sandbox and this API cannot abused.
To make your code work, use:
if(usnafeWindow.top != unsafeWindow.self) return;
Please note the unsafe
part, you may want to review these pages:
Alternatively, wrap the code in a <script>
tag:
(function(f){var d=document,s=d.createElement('script');s.setAttribute('type','application/javascript');s.textContent = '('+f.toString()+')()';(d.body||d.head||d.documentElement).appendChild(s);s.parentNode.removeChild(s)})(function(){
/* code here */
}
Upvotes: 2