Intoli

Intoli Remote Browser Tour

The Power of the Web Extensions API

So far, we've mostly used the Web Extensions API for navigating tabs to new URLs. That's certainly useful, but it's really just scratching the surface of what the API is capable of. The Web Extensions API is extraordinarily powerful, and you can use it to do many of the same things for which you might use Puppeteer, Selenium, or Nightmare. You can take screenshots, intercept and modify requests/responses, modify proxy settings, manage cookie sessions, change cache settings, and a whole lot more. Plus you can do all of this in a cross-browser compatible way with basically zero overhead compared to projects like ChromeDriver and GeckoDriver.

In the example to the right, you can see how we can use the Web Extensions API to take a screenshot of a tab using browser.tabs.captureVisibleTab. As a bonus, you can see where your remote browser instance is actually running!

5/7
import Browser from 'remote-browser';
// Launch a remote browser instance.
const browser = new Browser();
await browser.launch();
// Navigate to a "What's My IP Address" page
    which displays a map.
const url = 'https://www.privateinternetaccess
    .com/pages/whats-my-ip/';
const tab = await browser.tabs.update({ url });
await browser[tab.id].readyState('complete');
// Take a screenshot and log it.
const screenshot = await browser.tabs
    .captureVisibleTab();
console.log(screenshot);
// Clean up the browser instance.
await browser.quit();
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX