Skip to content

jarrodcolburn/chromeapi

Repository files navigation

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
    • Customize the build command flutter build web --web-renderer html --csp (for this project in the example directory)
    • or reference on Building Chrome Extension using Flutter

Usage

import 'package:chromeapi/chromeapi.dart';

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;
}

Above function is used in example package, an Chrome Extension that, when clicked, generates a QR code for url from the active tab.

Note, if using Flutter make sure to avoid naming collision, example...

// chromeapi also imports a 'Tab' class
import 'package:flutter/material.dart' hide Tab;

About

Flutter Chrome Extension API

Resources

License

Stars

6 stars

Watchers

1 watching

Forks

Packages

 
 
 

Contributors