更新时间:2023-12-05 19:39:04
好的,你应该看看 chrome.browserAction.setIcon
文档 。
$ b
Well, you should take a look at the chrome.browserAction.setIcon
documentation.
整数(可选)
tabId
限制选择特定选项卡时的更改。当标签关闭时自动重置。
Limits the change to when a particular tab is selected. Automatically resets when the tab is closed.
正是需要的!现在,标签ID是在发件人$ c $中报告的
$ b
Just what was needed! Now, the tab ID is reported in the sender
parameter:
chrome.runtime.onMessage.addListener(
function(request, sender, sendResponse) {
if( request.message === "Existing" ) {
chrome.browserAction.setIcon({
path:"OKicon.png",
tabId: sender.tab.id
});
}
if( request.message === "Not Existing" ) {
chrome.browserAction.setIcon({
path:"NOKicon.png",
tabId: sender.tab.id
});
}
}
);