Perform a function on a web page?

Say the webpage has a feature like:

function abc (){
return 'abc';
}

How do I execute and get the return value of this function from my extension? I tried this, no dice:

var s = getBrowser.contentWindow.abc();

Thanks in advance!

+3
source share
2 answers

I think I solved my problem:

getBrowser().contentWindow.wrappedJSObject.funcFromPage();
-1
source

I think that if you want to do this without serious security issues, you need to use XPCSafeJSObjectWrapper, but I have problems finding good documentation. https://developer.mozilla.org/en/XPConnect_wrappers has a bit. (Perhaps this happens automatically when doing the above, but I'm not sure.)

0

Source: https://habr.com/ru/post/1756354/


All Articles