Calling webpage JavaScript methods from browser extension

前端 未结 1 1165
耶瑟儿~
耶瑟儿~ 2020-11-27 09:00

I am developing an firefox extension using webExtensions that would help me ease my work with the scenario below.

I have to click around 50-60 butto

1条回答
  •  轮回少年
    2020-11-27 09:13

    Your content script is in a different context/scope from that of page scripts (scripts that already exist in the webpage). Your content script has higher privileges than are granted to page scripts. Keeping content scripts separate from page scripts is a normal architecture for browser extensions, which is done for security reasons.

    Because your content script is in a different context from page scripts, you can't directly access functions and variables that are defined in page scripts from your content script. There are a few different ways which you can access information in the page context. The cross-browser method of doing so is to cause some specific parts of your code to execute in the page context. I find the most convenient, and cross-browser compatible, way to do so is to create and insert a

提交回复
热议问题