Is there any way to replace content's JS function from add-on ?
Hi,
I have a page, I have to work to from my add-on and it contains
errorneous javascript functions.
Is there any way to replace it from my add-on? I tried something like
this, but with no success:
var win = content.frames[1];
alert(win); // shows XPCNativeWrapper[object Window]
alert(win['formatoFecha']); // shows 'undefined', but such a function
presents in the frame, for sure.
win['formatoFecha'] = function (fecha) {
if (fecha==null)
return "";
else {
var anio=fecha.getYear();
if (anio<200) anio=1900+anio;
return fecha.getDate()+"-"+(fecha.getMonth()
+1)+"-"+anio;
}
};
alert(win['formatoFecha']); // shows assigned value, but page still
use old function.
Any ideas?
Thanks in advance.
--
WBR,
Serge.
Re: Is there any way to replace content's JS function from add-on ?
On 19 ΣΕΞ, 11:31, Nickolay Ponomarev <asquee...@gmail.com> wrote:
[color=blue]
> [url]http://www.google.com/search?q=xpcnativewrapperhttps://developer.mozilla.org/en/Safely_accessing_content_DOM_from_ch...https://developer.mozilla.org/en/XPCNativeWrapper[/url][/color]
I did it, sure :-)
[url]http://groups.google.com/group/mozilla.dev.extensions/msg/3ba40f23b0b[/url]...
Thanks, I'll try to play with Sandbox functionality
--
WBR,
Serge
Re: Is there any way to replace content's JS function from add-on ?
Hi John, thanks for the reply.
[color=blue]
> You attached the function to the wrapper, not the window.[/color]
Yes, I got it. I'd better to ask how to bypass XPCNativeWrapper and
get to "native" window. I'll try to play with Sandbox functionality as
Nikolay suggested.
[color=blue]
> The operation
> of writing on the win object from the extension is supposed to be
> illegal. However it is allowed, only it does not alter the page. It does
> alter the wrapper, so that is why the last alert works. I think it is a
> design flaw: I think the operation ought to fail.[/color]
Agreed. The only reason why I'm trying to do it is - that bloody page
isn't under my control and my add-on have to work with it.
--
WBR,
Serge.