小编jen*_*ush的帖子

Chrome扩展程序:加载并执行外部脚本

我无法在我的chrome扩展程序中加载和执行外部js-script.看起来和这个问题一样,但我仍然无法弄清楚为什么它在我的情况下不起作用.

我的想法是,我希望在我的内容脚本中有一些默认函数,它应该解析网页内容.对于某些特定的网页,我想加载和使用特定的解析器,所以我尝试为wep页面加载正确的js-script,这个脚本应该扩展默认解析器的功能.

到现在为止我只尝试从外部脚本执行代码,但是有这样的错误: Unchecked runtime.lastError while running tabs.executeScript: No source code or file specified at Object.callback

这是我的manifest.json:

{
"name": "Extension name",
"version": "1.2",
"description": "My chrome extension",
"browser_action": {
    "default_popup": "popup.html",
},
"content_scripts": [{
    "css": [
        "style.css"
    ],
    "js": [
        "bower_components/jquery/dist/jquery.js",
        "bower_components/bootstrap/dist/js/bootstrap.js",
        "content.js"
    ],
    "matches": ["*://*/*"]
}],
"web_accessible_resources": [
    "frame.html",
    "logo-48.png"
],
"icons": {
    "16": "logo-16.png",
    "48": "logo-48.png",
    "128": "logo-128.png"
},
"permissions": [
    "tabs",
    "storage",
    "http://*/",
    "https://*/"
],
"manifest_version": 2
Run Code Online (Sandbox Code Playgroud)

}

这是popup.html

<!doctype html>
 <html> …
Run Code Online (Sandbox Code Playgroud)

javascript external-script google-chrome-extension

8
推荐指数
2
解决办法
9700
查看次数