1

我正在尝试使用此文档创建扩展: http ://code.google.com/chrome/extensions/content_scripts.html

我希望在文档准备好(加载)时运行一部分 JS 代码。

这是我的manifest.json

{
    "name": "OwnExtension",
    "version": "0.1",
    "content_scripts": [
    {
        "matches": ["https://my.site.eu/*"],
        "css": ["styles.css"],
        "js": ["main.js"]
    }
    ]
}

这是我的main.js

alert(10);

我做错了什么,当页面https://my.site.eu/加载到浏览器中时没有发生任何事情?

4

1 回答 1

2

alert() 不适用于内容脚本。

试试 console.log("hello") 当你在调试模式下查看你的扩展时,你应该在开发者面板中看到它。

于 2010-06-18T19:31:11.987 回答