Chrome Extensions API

Features

Project is WIP, starting with chrome.tabs mostly implemented (methods, not events).

Prerequisites

  • Set permissions in manifest.json required to use specifc API's according found at Chrome Reference
  • If building with Flutter,
    • Make the appropriate changes to the normal working directory/files.
      • Examples:
        • manifest.json (example: service workers)
        • index.json

Usage

Import the package. `import 'package:chromeapi/chromeapi.dart';

Use the chrome object. Currently only chrome.tabs works.

See example on getting the active tab.

Future<Tab> getActiveTab() async {
  QueryInfo queryInfo = QueryInfo(active: true, lastFocusedWindow: true);
  List<Tab> tabs = await chrome.tabs.query(queryInfo);
  final tab = tabs.singleWhere((tab) => tab.url != null && tab.url!.isNotEmpty);
  return tab;
}

Libraries

chromeapi