我可以将 Mootools 框架包含在 Chrome 扩展的后台页面中吗?

发布于 2025-01-08 14:11:02 字数 1286 浏览 0 评论 0原文

如标题,我想知道是否可以将 Mootools 框架包含到 Chrome 扩展的后台页面中? 我尝试过但没有成功。

背景页:

<!doctype html>
<html>
  <head>
    <title>Background Page</title>
    <script src="mootools-more-1.4.0.1.js" type="text/javascript"></script>
    <script src="mootools-core-1.4.2-full-compat.js" type="text/javascript"></script>
    <script src="script.js"></script>
  </head>
  <body>
  </body>
</html>

清单:

{
    "name": "First Extension",
    "version": "1.0",
    "description": "The first extensione tha I made",
    "permissions":["contextMenus"],
    "background_page": "background_page.html",
    "browser_action":{ 
                        "name": "My First Extension!",
                        "default_icon": "Chrome_icon32bn.png",
                        /*"default_popup": "popup.html",*/
                        "default_title": "My First Extension!"
    },
    "icons": {
                "16": "Chrome_icon19color.png",
                "48": "Chrome_icon32color.png",
                "128": "Chrome_icon.png"
    },
    "content_scripts": [{ "js": ["https://ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools-yui-compressed.js"] }]

}

As title, I would know if can I include Mootools framework into background page of Chrome Extension?
I tried but without success.

Background page:

<!doctype html>
<html>
  <head>
    <title>Background Page</title>
    <script src="mootools-more-1.4.0.1.js" type="text/javascript"></script>
    <script src="mootools-core-1.4.2-full-compat.js" type="text/javascript"></script>
    <script src="script.js"></script>
  </head>
  <body>
  </body>
</html>

Manifest:

{
    "name": "First Extension",
    "version": "1.0",
    "description": "The first extensione tha I made",
    "permissions":["contextMenus"],
    "background_page": "background_page.html",
    "browser_action":{ 
                        "name": "My First Extension!",
                        "default_icon": "Chrome_icon32bn.png",
                        /*"default_popup": "popup.html",*/
                        "default_title": "My First Extension!"
    },
    "icons": {
                "16": "Chrome_icon19color.png",
                "48": "Chrome_icon32color.png",
                "128": "Chrome_icon.png"
    },
    "content_scripts": [{ "js": ["https://ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools-yui-compressed.js"] }]

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤云独去闲 2025-01-15 14:11:02

是的,但由于扩展程序运行时您处于沙箱中,因此必须以不同方式加载它:

将其添加到清单中

{
  "name": "My extension",
  "content_scripts": [
    {
      "js": ["https://ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools-yui-compressed.js"]
    }
  ]
}

Yes but because you are in a sandbox when the extension is running you must load it differently:

Add this to the manifest

{
  "name": "My extension",
  "content_scripts": [
    {
      "js": ["https://ajax.googleapis.com/ajax/libs/mootools/1.4.1/mootools-yui-compressed.js"]
    }
  ]
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文