Google chrome 正在尝试向Google chrome扩展添加通知

Google chrome 正在尝试向Google chrome扩展添加通知,google-chrome,google-chrome-extension,Google Chrome,Google Chrome Extension,我试图将通知添加到google chrome扩展中,这意味着每当我的网站上有新帖子时,通知就会在扩展图标上显示一个红色的小框,没有1-10,就像google chrome中的Feedly扩展或Unextertherapy扩展一样。显示这样的通知应该很简单: var notification = '#FA2E05' function showNotification() { chrome.browserAction.setBadgeText({text: ' '}); chrome.b

我试图将通知添加到google chrome扩展中,这意味着每当我的网站上有新帖子时,通知就会在扩展图标上显示一个红色的小框,没有1-10,就像google chrome中的Feedly扩展或Unextertherapy扩展一样。

显示这样的通知应该很简单:

var notification = '#FA2E05'
function showNotification() {
   chrome.browserAction.setBadgeText({text: ' '});
   chrome.browserAction.setBadgeBackgroundColor({color: notification});
}

function clearNotification() {
   chrome.browserAction.setBadgeText({text: ''});
}
以下是我在使用徽章时常用的一个助手:

function updateBadge(options) {
    var t = options.text,
        c = options.color||options.colour;

    if(t !== undefined){
        chrome.browserAction.setBadgeText({text: (t||'')});
    }
    if(c !== undefined) {
        chrome.browserAction.setBadgeBackgroundColor({color: c});
    }
}
这使您可以使用
updateEdge({text:'55'})
//保持相同的颜色或

updateEdge({color:'#FA2E05',文本:'})
//显示徽章(相当于showBadge())

在何处添加此文件这是我的js文件,类似于codehttps://docs.google.com/file/d/0B_b7vutPyv8gWDdMM011bThySGs/edit?usp=sharingSomewhere 在您想要更改徽章之前,我个人将这些函数保存在
浏览器
对象中,我将其用作主要javascript代码的依赖项。如果将来我想将扩展移植到其他浏览器,这将非常有用。因此,如果我想更改脚本中任何位置的徽章(假设我的
browser.js
文件已加载),我可以调用
browser.updateEdge({text:33,color:'#7D4E45'})
。请你帮我一下,我不知道如何修改它。把徽章带到通知处。是的,就像那样,徽章上显示数字1-10。不意味着(最新的帖子)您的分机目前没有图标(在分机托盘上)?