Untitled

 avatar
unknown
plain_text
6 days ago
657 B
5
Indexable
// Listen for the extension installation or update event
chrome.runtime.onInstalled.addListener(() => {
  console.log('Extension installed or updated!');
});

// Listen for messages from content scripts or popups
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
  if (message.action === 'greet') {
    console.log('Received greeting from:', sender.tab.url);
    sendResponse({ reply: 'Hello from the background script!' });
  }
});

// Listen for tab updates
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
  if (changeInfo.status === 'complete') {
    console.log('Tab updated:', tab.url);
  }
});
Leave a Comment