CBA version 10.0 and MV3 compliance: bg-inject deprecation and changes to cs-inject Release notes CBA 10.0

CBA

Chromium Browser Automation (extension for chrome browser automation)

bg-inject

bg-inject is deprecated since CBA version 10.0

Since Manifest Version 3 it's not allowed to evaluate script in the context of the extension, meaning CBA users can no more use bg-inject command. Previously bg-inject was used for injecting script into the background page of the extension where you can also access browser api and create very flexible and powerful Automation. Currently only extension hosted code can be executed in the context of the background page and the only way to do it is by using bg-function command. I am happy to accept commands you have used with bg-inject and add them to the bg-function command, so please let me know by filing an issue or feel free to creating a PR. Please let me know about your use-cases that you can no more support with the new MV3 compliance rules, I will try helping you there.

Learn more about MV3 compliance changes.

bg-inject in CBA version 9.0 and less

bg-inject provides ability of injecting script into backroung page of the extension where you can also access browser api.

browser.tabs.create({url: "https://example.org"});

Clipboard

It's handy to use clipboard object to pass data from the page to the bg-inject actions.

#page-url
browser.tabs.create({url: clipboard["copy"]});

actionToPlay

actionToPlay function is used for jumping to another action.

if (clipboard["jumpToFirstAction"])
{
  actionToPlay(1);
}

async/await

You can also use async/await in the bg-inject that way you can wait for an async function execution before proceeding with the next action.

const [tab] = await browser.tabs.query({active: true});
await browser.tabs.remove(tab.id);