Skip to content

Inject snippets as bundles

Background

The snippets module adopted a bundling approach splitting the snippets.js file into multiple files (one per each snippet + helpers). In the end, the snippets module provides 2 bundles: one for injected snippets and one for isolated snippets.

What to change

Alter the compileScript API in order to accept both bundles and to inject them accordingly.

Integration Notes

The signature of the compileScript API is changed. The parameters are the following:

  • string|Array.string scripts - same as before
  • string isolatedSnippetsLibrary - the stringified bundle to be executed in the isolated content script context
  • string injectedSnippetsLibrary - the stringified bundle to be injected and executed in the main context
  • string|Array.string injectedSnippetsList - an array containing the available injectable snippets
  • object environment - same as before

The return value's purpose is unchanged: it's the code string that will be passed to chrome.tabs.executeScript in order to be executed at contentScript level.

Edited by Alexandru Daniel Roman