我正在构建一个覆盖新标签的Chrome Extension
。我设法用我的HTML文件和页面标题覆盖新选项卡。但是,favicon不会显示在新选项卡上,也不会显示错误。
这是我的manifest.json
:
{
"manifest_version": 2,
"name": "Hello World",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"chrome_url_overrides" : {
"newtab": "hello_world.html"
},
"permissions": [
"activeTab",
"tabs"
]
}
以下是hello_world.html
:
<html>
<head>
<title>Hello World</title>
<link rel="shortcut icon" href="favicon.ico"/>
</head>
<body>
<div>Hello World</div>
</body>
</html>
我在docs
中找不到有关新标签上的favicon的内容。
答案 0 :(得分:1)
您必须在清单中将favicon.ico
添加到web_accessible_resources,以便hello_world.html
可以访问它。然后,您必须动态更改您的favicon的href
到chrome.extension.getURL("favicon.ico")
的结果。
将此添加到您的清单:"web_accessible_resources": [ "favicon.ico" ]
编辑:删除了代码示例,因为它没有工作并添加了新代码。
如果您覆盖history
或bookmarks
页面,则此代码正常工作,因为默认情况下它们具有favicon。只需在清单中更改此内容,即可试用head
hello_world.html
<title>Hello World</title>
<link rel="shortcut icon" href="chrome-extension://{ID OF YOUR EXTENSION}/favicon.ico" />
到下面的代码。
newtab
遗憾的是,无法在public static void main(String[] args) throws IOException {
String fromclient;
ServerSocket Server = new ServerSocket(25000);
System.out.println("TCPServer Waiting for client on port 25000");
while (true) {
Socket connected = Server.accept();
System.out.println(
" THE CLIENT" + " " + connected.getInetAddress() + ":" + connected.getPort() + " IS CONNECTED ");
PrintWriter out = new PrintWriter(connected.getOutputStream(), true);
Scanner sc = new Scanner(System.in);
while (true) {
String input = sc.nextLine();
out.println(input);
}
}
}
页面添加图标。我希望没有它可以活下去;)