gpt4 book ai didi

javascript - Chrome 扩展 : Open html in the crx file with no icon on tab

转载 作者:搜寻专家 更新时间:2023-10-31 08:54:34 24 4
gpt4 key购买 nike

您好,我正在开发一个简单的 chrome 扩展程序,它通过在扩展程序的 .crx 目录中打开一个 index.html 来替换当前默认的新标签页。

目前新标签页已经修改为新的index.html页面,但是标签上没有图标。

请问为什么?非常感谢!

当前打开新标签页标签上没有图标的问题

Current Problem

扩展目录如下所示:

directory

ma​​nifest.json代码如下

{
"manifest_version": 2,
"name": "千山",
"version": "0.1.0",
"description": "测试",
"icons": {"16": "icon200.png", "48": "icon200.png", "128": "icon200.png"},
"browser_action": {
"default_icon": "icon.png" ,
"default_title": "测试",
"default_popup": "popup.html"
},
"chrome_url_overrides": {
"newtab": "index.html"
}
}

index.html的head是这样的,我自己写的,但是没有显示出来

<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>千山</title>
<!-- Bootstrap -->
<link href="bootstrap.min.css" rel="stylesheet">
<link rel="icon" href="fav.ico" type="image/x-icon">

最佳答案

您需要将相对路径“fav.ico”替换为文件的完整扩展名路径。在 JavaScript 中,您可以通过调用 chrome.runtime.getURL("fav.ico") 获取完整路径。

如果您知道完整路径并采取预防措施以确保您的扩展 ID 不会随时间改变(通过始终使用相同的 key.pem 文件发布),那么硬编码path 将起作用并且不需要任何 JavaScript。

可能还需要将“fav.ico”添加到manifest.jsonweb_accessible_resources 部分:

{
"web_accessible_resources": [
"fav.ico",
"bootstrap.min.css"
]
}

关于javascript - Chrome 扩展 : Open html in the crx file with no icon on tab,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29802740/

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