I tried that! :p
This was my code:
codigoNuevo = document.createElement("script");
codigoNuevo.innerHTML = '<script>' +
'Silenciar()' +
'</script>';// Entre las comillas escribimos el codigo a introducir
document.body.insertBefore(codigoNuevo, document.body.lastChild);
Where Silenciar() is a function defined in the Video.js (the script
called at the end of the real page). With that code I tried put it
after the call to Video.js. It do?
Because I don't know so much about javascript and greasemonkey I wrote
that by copy from some parts of examples of dive into greasemonkey :p
But the code doesn't work... xD
I think by inyecting code is a good way to reach my objetive :D
By the way, I'll no use unsafeWindow again.
On 16 sep, 05:48, cc <[email protected]> wrote:
> elfio wrote:
> > (snip)
> >> No, you will not. Like I said above, user scripts are separate. (You
> >> _could_ access them, with unsafeWindow: but like the name says, it is
> >> unsafe! You should not use it.)
>
> > But I need access to some variables of the page. How can I do it
> > without use unsafeWindow?
>
> Probably the easiest way to do this is by injecting part of the script
> into the page. That way, the script you inject runs as though it was
> included in the page, and has full access to all the page's variables,
> functions, etc, but has no direct access to various privileged
> Greasemonkey APIs. To do this, append a <script> element to the page
> with contents set to whatever you're injecting; it's easiest to inject
> whole functions, because you can simply do something like the following:
>
> function example(param1, param2) {
> // Do something with its parameters
> return param1.toString() + param2.toString();}
>
> var elemScript = document.body.appendChild(document.createElement("script"));
> elemScript.innerHTML = example + "\n\n window.alert(example(1,2)); // Call
> example from in-page code";
>
> and the function's source will be included in that <script> element
> without much work.
>
> By the way, when Anthony says something is unsafe, he unfortunately
> means it. unsafeWindow can be *very* unsafe, because it allows the most
> seemingly innocent of script operations to be perverted by a malicious
> web page and do all kinds of nasty things with e.g. Firefox internals --
> for example, making unrestricted cross-domain requests (to your bank,
> perhaps?); performing denial-of-service attacks with GM_setValue; and
> all kinds of other things.
> Don't use it.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---