gpt4 book ai didi

javascript - 如何在 Chrome 扩展中的新选项卡上加载 url 覆盖脚本?

转载 作者:行者123 更新时间:2023-11-30 00:11:21 24 4
gpt4 key购买 nike

我的 manifest.json 看起来像这样。

    {
"manifest_version": 2,

"name": "Getting started example",
"description": "This extension shows a Google Image search result for the current page",
"version": "1.0",

"chrome_url_overrides" : {
"newtab": "a.html"
}
}

我想在 a.html 中包含 myScript.js 和 jquery.js。

我试过在 a.html 上使用脚本标签(因为内联脚本不允许)。

涉足内容脚本和背景页面。但我不认为我需要这里的内容脚本,因为我不是在寻找与当前页面内容的交互。我认为这可以通过背景页面来完成,但它似乎不是工作。我尝试将 "background": { "scripts": ["jquery.js", "myScript.js"] } 添加到 manifest.json 但它似乎不起作用。

如何将 myScript.js 和 jquery.js 添加到 a.html。

P.S.:所有文件都在同一目录中。

最佳答案

尝试添加外部 JS:

<script src="myScript.js"></script>

到 a.html 页面并创建 myScript.js 并在其中编写您的 JS 代码。

关于javascript - 如何在 Chrome 扩展中的新选项卡上加载 url 覆盖脚本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36371463/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com