Can the window object be modified from a Chrome extension?

前端 未结 7 2040
甜味超标
甜味超标 2020-11-29 02:26

I would like to make a Chrome extension that provides a new object inside window. When a web page is viewed in a browser with the extension loaded, I would like

7条回答
  •  甜味超标
    2020-11-29 03:04

    Thanks to the other answers here, this is what I'm using:

    ((source)=>{
      const script = document.createElement("script");
      script.text = `(${source.toString()})();`;
      document.documentElement.appendChild(script);
    })(function (){
    
      // Your code here
      // ...
    
    })
    
    

    Works great, no issues.

提交回复
热议问题