Skip to content

use activeTab for getting active tab info from popup #2503

@tomholub

Description

@tomholub

We're trying to stop using the tabs permission if we can, in order to show less scary permissions when user is installing the browser extension. tabs permission causes Can read data on all websites warning, which is not what the extension actually does.

One way we use .tabs is to get information about active tab:

  public static getActiveTabInfo: Bm.AsyncRespondingHandler = () => new Promise((resolve, reject) => {
    chrome.tabs.query({ active: true, currentWindow: true, url: ["*://mail.google.com/*", "*://inbox.google.com/*"] }, (activeTabs) => {
      if (activeTabs.length) {
        if (activeTabs[0].id !== undefined) {
          type ScriptRes = { acctEmail: string | undefined, sameWorld: boolean | undefined }[];
          chrome.tabs.executeScript(activeTabs[0].id!, { code: 'var r = {acctEmail: window.account_email_global, sameWorld: window.same_world_global}; r' }, (result: ScriptRes) => {
            resolve({ provider: 'gmail', acctEmail: result[0].acctEmail, sameWorld: result[0].sameWorld === true });
          });
        } else {
          reject(new Error('tabs[0].id is undefined'));
        }
      } else {
        resolve({ provider: undefined, acctEmail: undefined, sameWorld: undefined });
      }
    });
  })

They say, for this we can instead use activeTab permission from the popup, which does not cause warning (meaning it should not cause app disabling either), see https://developer.chrome.com/extensions/activeTab

image

Originally posted by @tomholub in #2497 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions