“default_icon” 和 “icons” 在 Chrome 扩展中有什么区别?

huangapple go评论60阅读模式
英文:

What is the difference between "default_icon" and "icons" in a Chrome extention?

问题

在Chrome扩展的manifest.json文件中,"default_icon"属性和"icons"属性之间的区别是:

"default_icon"属性定义了默认的图标,它在扩展按钮未激活时显示。这个属性可以包含多个图标的尺寸,以适应不同的显示情况。例如,16x16像素、32x32像素和64x64像素大小的图标可以在不同的环境下使用。

"icons"属性则定义了扩展的其他图标,通常用于不同的上下文和显示情况。这些图标可以包含与"default_icon"不同的尺寸和样式。

总之,"default_icon"用于指定默认情况下扩展按钮的图标,而"icons"用于指定其他情况下可能需要的图标。

英文:

I was wondering what the difference was between the "default_icon" property and "icons" property in the manifest.json file in Chrome extensions?

{
	"name": "Chrome Extension",
	"description": "desc",
	"version": "1.0.0",
	"manifest_version": 3,
	"action": {
		"default_popup": "index.html",
		"default_icon": { // <-- The difference between this...
			"16":  "favicon-16x16.png",
			"32":  "favicon-32x32.png",
			"64":  "favicon-64x64.png"
		}
	},
	"icons": { // <-- ...and this
		"16":  "favicon-16x16.png",
		"32":  "favicon-32x32.png",
		"64":  "favicon-64x64.png"
	},
	"content_scripts": [{
		"css": ["style.css"],
		"matches": ["https://www.google.com/*"],
		"js": ["script.js"]
	}]
}

答案1

得分: 1

action.default_icon显示在扩展工具栏中,位于浏览器地址栏旁边。用户单击工具栏中的扩展图标时,可以显示弹出窗口,或在其上下文菜单中显示快速操作。

您还可以根据网页中的某些事件或更改以编程方式更新它。

icons中指定的图标是您扩展的标识符。它将用于chrome://extensions页面上的扩展详细信息卡片,并且还将用作扩展页面的网站图标。

英文:

action.default_icon is shown in the extension toolbar, next to address bar in the browser. You may show a popup when user clicks the extension icon in toolbar or show quick actions in its context menu.

You may also programmatically update it based on certain events or changes in webpage.

Whereas, the icon specified in icons is an identifier for your extension. It will be used in the extension details card on chrome://extensions page and also as favicon for the extension pages.

huangapple
  • 本文由 发表于 2023年8月10日 10:20:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76872268.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定