How do I execute a page-defined JavaScript function from a Firefox extension?

前端 未结 5 1920
感动是毒
感动是毒 2021-01-04 21:14

I\'m creating a Firefox extension for demo purposes. I to call a specific JavaScript function in the document from the extension. I wrote this in my HTML document (not insid

5条回答
  •  情歌与酒
    2021-01-04 21:42

    document.wrappedJSObject.funcToBeCalled();
    

    This is not secure and allows a malicious page to elevate its permissions to those of your extension... But, it does do what you asked. Read up on the early greasemonkey vulnerabilities for why this is a bad idea.

提交回复
热议问题