Google Chrome Extension - Script Injections

后端 未结 4 871
暗喜
暗喜 2020-12-07 23:04

I\'m trying to get my Chrome Extension to inject some javascript with content_scripts, using this previous answer as a reference.

4条回答
  •  渐次进展
    2020-12-07 23:29

    Another reason for getting this error is if the url is being blocked by CORS. Check the network request header of the page to see if it contains Content-Security-Policy:

    Content-Security-Policy: default-src 'self' http://example.com; connect-src http://example.com/; script-src http://example.com/
    

    You can try opening the url in a new browser tab to verify the image url is correct:

    chrome-extension://mjcbjlencnokpknflpneebajalcnnifo/images/pattern.jpg
    

    One way around this is to use an image data URI:

    data:image/gif;base64,R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7
    

提交回复
热议问题