我收到此错误“未捕获的类型错误:无法调用未定义的方法‘setBadgeText’”
这是我下面的代码:
这曾经在 Chrome 27.0 中有效,但现在在 Chrome 29.0 中似乎已经停止运行。我不确定是这个还是.. manifest.json 文件在后台加载它。
var DOCLIST_SCOPE = 'https://docs.google.com/feeds';
var DOCLIST_FEED = DOCLIST_SCOPE + '/default/private/full/';
var docs = []; // In memory cache for the user's entire doclist.
var refreshRate = localStorage.refreshRate || 300; // 5 min default.
var pollIntervalMin = 1000 * refreshRate;
var requests = [];
var oauth = ChromeExOAuth.initBackgroundPage({
'request_url': 'https://www.google.com/accounts/OAuthGetRequestToken',
'authorize_url': 'https://www.google.com/accounts/OAuthAuthorizeToken',
'access_url': 'https://www.google.com/accounts/OAuthGetAccessToken',
'consumer_key': 'anonymous',
'consumer_secret': 'anonymous',
'scope': DOCLIST_SCOPE,
'app_name': 'App Name'
});
function setIcon(opt_badgeObj) {
if (opt_badgeObj) {
var badgeOpts = {};
if (opt_badgeObj && opt_badgeObj.text != undefined) {
badgeOpts['text'] = opt_badgeObj.text;
}
if (opt_badgeObj && opt_badgeObj.tabId) {
badgeOpts['tabId'] = opt_badgeObj.tabId;
}
chrome.browserAction.setBadgeText(badgeOpts);
}
};
function clearPendingRequests() {
for (var i = 0, req; req = requests[i]; ++i) {
window.clearTimeout(req);
}
requests = [];
};
function logout() {
docs = [];
setIcon({'text': ''});
oauth.clearTokens();
clearPendingRequests();
};