INNER CODE UNIT · JavaScript

sendToTab

kevinchin12/ImageLens · background.js:136

function sendToTab(tab, message) {
  if (tab?.id === undefined) return;

  chrome.tabs.sendMessage(tab.id, message, { frameId: 0 }).catch((error) => {
    // Pages opened before the extension was installed or updated, and
    // chrome:// pages, have no content script to receive the message.
    console.warn("[Image Lens] Could not reach the page. Reload it and try again.", error);
  });
}

async function handleMessage(message, sender) {
  switch (message.type) {
    case "get-settings":
      return getSettings();
    case "save-settings":
      return saveSettings(message.payload || {});
    case "analyze-image":
      return analyzeImage(message.payload || {}, sender);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…