如何在chrome扩展中的新选项卡上加载url覆盖的脚本

How to load scripts on url override on new tab in chrome extension?

本文关键字:加载 脚本 覆盖 url 选项 chrome 扩展 新选项      更新时间:2023-11-05

我的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"
      }
    }

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

我尝试过在.html上使用脚本标记(不允许使用内联脚本)。

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

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

附言:所有文件都在同一个目录中。

尝试将外部JS添加为:

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

到.html页面,创建myScript.js并在其中编写js代码。