图标上的 Google Chrome 扩展程序编号 [英] Google Chrome Extension Numbers on the Icon
问题描述
我一直在试验 Chrome 扩展程序,我想制作一个类似于我的 Google 语音扩展程序的扩展程序,当我收到一个事件时,图标旁边会显示一个蓝色的小1",这是一个完全独立的吗?图标?然后他们只使用setIcon"方法?像这样
I've been experimenting with a Chrome Extension, and I want to make one similar to my Google Voice Extension where the icon shows a little blue "1" next to the icon when I receive an event, Is this a whole separate icon? and then they just use the "setIcon" method? Like this
chrome.browserAction.setIcon({path:"icon.png"});
以下是它的外观示例:
gmail 似乎高达 500!他们不能为每个数字都有一个图标,或者是吗??有什么我可以用来做这些东西的东西吗?我已经有了我的图标,如果我必须制作一个独特的图标,我可能只制作 10 个,然后有一个10+"图标.我正在将它连接到一个可能有很多事件的 API.
The gmail one seems to go all the up to 500! They can't have an icon for each number, or do they?? Is there something I can use thats made to do this stuff? I already have my icon, if I have to make a unique one I may just make like 10 and then have a "10+" icon. I am connecting it to an API which could have a lot of events.
有人遇到过这个问题吗?他们是怎么解决的?
Has anybody had this issue? How did they get around it?
任何意见或建议都会有所帮助!
Any advice or suggestions would help!
谢谢!
推荐答案
您可以设置 在浏览器操作上添加 noreferrer">徽章
setBadgeText:
You can set a badge on your browser action with setBadgeText
:
chrome.browserAction.setBadgeText({text: "10+"}); // We have 10+ unread items.
请注意,如果您传递的文本长度超过 4 个字符,则会被截断为前 4 个字符.
Note that if the text you pass is longer than 4 characters, it will be truncated to the first 4 characters.
根据新的 Manifest V3,API 已更改.根据文档:在 Manifest V3 中,chrome.browserAction 和 chrome.pageAction API 合并为一个 chrome.action API.
According to the new Manifest V3, the APIs have been changed. According to the document:
In Manifest V3 the chrome.browserAction and chrome.pageAction APIs are consolidated into a single chrome.action API.
因此,您遵守新 API 的代码应为:
So, your code for adhering to the new API shall be:
chrome.action.setBadgeText({text: "10+"}); // We have 10+ unread items.
这篇关于图标上的 Google Chrome 扩展程序编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!