mirror of
https://github.com/fergalmoran/podnoms.git
synced 2025-12-25 18:58:12 +00:00
26 lines
1.0 KiB
JavaScript
26 lines
1.0 KiB
JavaScript
'use strict';
|
|
console.log('Background');
|
|
chrome.runtime.onMessage.addListener(function(event, sender, sendResponse) {
|
|
if (event.type === 'updatebadge') {
|
|
chrome.tabs.get(sender.tab.id, function(tab) {
|
|
// chrome.pageAction.show(tab.id);
|
|
if (chrome.runtime.lastError) {
|
|
return;
|
|
}
|
|
if (tab.index >= 0) {
|
|
chrome.browserAction.setBadgeBackgroundColor({ tabId: tab.id, color: [255, 0, 0, 255] });
|
|
chrome.browserAction.setBadgeText({ tabId: tab.id, text: event.data });
|
|
} else {
|
|
var tabId = sender.tab.id,
|
|
text = event.data;
|
|
chrome.webNavigation.onCommitted.addListener(function update(details) {
|
|
if (details.tabId == tabId) {
|
|
chrome.browserAction.setBadgeText({ tabId: tab.id, text: event.data });
|
|
chrome.webNavigation.onCommitted.removeListener(update);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|