Connect+Documentation
ExtensionsAPI reference

connect.history

Read, search, and prune the profile's browsing history.

Read and prune the profile's browsing history. Reading needs history.read; deleting needs history.write. Like all data namespaces, it only ever touches the extension's own profile.

  • Capabilities: history.read (list/search), history.write (delete)
  • Namespace: connect.history

Walkthrough

Show recent history with search.

  1. Declare history.read (and history.write if you'll delete):
    { "capabilities": ["history.read"] }
  2. Feature-detect before reading — the user may not have granted it:
    if (await connect.capabilities.contains('history.read')) render(await connect.history.list({ limit: 50 }));
  3. Search on demand with search(query).
  4. Prune entries with delete(id) (needs history.write).

Methods

history.list(options?)

List history entries, newest first.

How to use it

  1. Pass { limit } for a page size (and offset to page).
  2. await the array of entries.

Signatureconnect.history.list({ limit?, offset? }) · Capability: history.read

Parameters

ParameterTypeRequiredDescription
limitnumbernoPage size.
offsetnumbernoSkip this many (for paging).

ReturnsPromise<HistoryEntry[]>.

Errors — rejects with code: 'CAPABILITY_DENIED' without history.read.

const recent = await connect.history.list({ limit: 50 });

history.search(query, limit?)

Search history by text.

How to use it

  1. Pass a query string (matched against title / URL) and an optional limit.
  2. await the matches.

Signatureconnect.history.search(query, limit?) · Capability: history.read

Parameters

ParameterTypeRequiredDescription
querystringyesMatch against title / URL.
limitnumbernoMax results.

ReturnsPromise<HistoryEntry[]>.

const hits = await connect.history.search('example.com', 20);

history.delete(id)

Delete one history entry.

How to use it

  1. Pass the entry's id (from a list / search result).
  2. Requires history.write.

Signatureconnect.history.delete(id) · Capability: history.write

Parameters

ParameterTypeRequiredDescription
idstring | numberyesThe entry's id.

ReturnsPromise<void>.

Notes

  • Feature-detect before reading: if (await connect.capabilities.contains('history.read')) — the user may grant write but not read, or neither.

On this page