Can I inject a CSS file programmatically using a content script js file?

前端 未结 3 1610
感情败类
感情败类 2020-12-08 08:04

Can I inject a CSS file programmatically using a content script js file?

It is possible for me to inject the css when the js file is linked to my popup.html. The pro

3条回答
  •  猫巷女王i
    2020-12-08 08:50

    It's to simple you could add to the manifest's permissions field : See web_accessible_resources

     , "web_accessible_resources": [
            "mystyle.css"
        ]
    

    and also add this in content_scripts

    "content_scripts": [
        {
            "matches": [""],
            "css": ["mystyle.css"],
            "js": ["jquery-1.10.2.min.js","content.js","my.min.js"]
        }],
    

    you also add same thing using Programmatic injection and insertCSS().

    chrome.tabs.insertCSS(integer tabId, object details, function callback)
    

提交回复
热议问题