Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension

前端 未结 3 1021
感情败类
感情败类 2020-12-14 06:56

I have tried many ways( all documented procedures)to inject script into a specific page upon checking URL at onUpdated.addListener. Finally the below code with \'executescri

3条回答
  •  生来不讨喜
    2020-12-14 07:29

    EDIT:

    This is working version where combination of web_accessible_resources and Injection is used

    manifest.json

    {
    "name":"Off Screen Tabs Demo",
    "description":"This demonstrates Off Screen Tabs API",
    "manifest_version":2,
    "version":"1",
    "permissions":["tabs",""],
    "browser_action":{
        "default_icon":"screen.png",
        "default_popup":"popup.html"
    },
     "web_accessible_resources": ["js/LeoScript.js"] ,
     "permissions":["tabs",""]
    }
    

    LeoScript.js

    alert("Injected..");
    

    popup.html

    
    
    
    
    
    
    
    

    popup.js*

    document.addEventListener("DOMContentLoaded",function (){
        chrome.tabs.executeScript( {"file": "js/LeoScript.js"});
    });
    

    Let me know if you still have problem in getting it running

提交回复
热议问题