Automation in Octo Browser: slashing the time costs

AUGUST 1, 2023 PRIVACY & ANONYMITY EXPERT OPINION
How to become a popular streamer from scratch
Artur Hvalei
Technical Support Specialist, Octo Browser
When you work with multiple profiles in a multi-accounting browser, you’re investing a lot of time, resources, and energy, even if the UX you’re running is close to perfection. More profiles simply mean more routine repeated actions that are so time-consuming that sometimes you hardly seem to notice that your work shift is already over. But what if we told you that a significant part of these actions can be automated, so that you can save the most valuable resource — your time?

Clicks, following links, and entering data can all be automated and thus significantly sped up in the browser. In this article we will tell you how to do precisely that.

Table of contents

Getting started with API

We have analyzed our users’ API calls and noticed that many teams are actively implementing scripts to manage profiles, in so doing changing the common approaches to multi-accounting. Our current API allows you to create profiles with the digital fingerprints you need, add proxies, assign tags, as well as start and stop automatic scenarios using any browser automation framework. You can also work with your profiles in a hybrid mode, making the most of combining the benefits of automation with the fine-tweaking traditional manual control of your accounts allows.
You can find your API token in the Additional settings of your Octo Browser Master Account

You can find your API token in the Additional settings of your Octo Browser Master Account.

Your API token

Octo Browser gives you access to your API token starting with the Base subscription and higher. Your API call limits are determined by your subscription.

Choosing the programming language

While this is a complicated subject that demands a separate discussion of possible combinations of programming languages and libraries, we will use Node.js + Axios for our example, as it is a common stack described in our Knowledge Base in detail. While C/С# or other languages might be faster, they have their own fields of application and limitations. Of course, you can choose any language that best suits your experience.

Using AI to rewrite code

We love good code automation and optimization ourselves, so we often use AI to rewrite the code we need in the language we need. You can use ChatGPT to rewrite the code using the following prompt:
Node.js code for the Axios library
Expand
Convert this script in Node.js with Axios into Python with the Requests library.

```
const axios = require('axios');
const ext = ['aapfglkgnhmiaabhiijkjpfmhllaodgp@4.2.3']; //UUIDs of extensions
const pageURL = 'https://app.octobrowser.net/api/v2/automation/profiles?page_len=100&page=';
const profilesURL = 'https://app.octobrowser.net/api/v2/automation/profiles/';
const pagesNumber = 2; /*2 number of pages, you should check number of your pages and modify it here(100 profiles on page maximum)
Ex: If you have 170 profiles, you have 2 pages.*/
const OCTO_TOKEN = "TOKEN" //token should be here
function sleep(ms) {
return new Promise((resolve, reject) => {
setTimeout(() => {
try {
resolve();
} catch (error) {
reject(error);
}
}, ms);
});
}
const getProfiles = {
method: "GET",
url: '',
headers: {
'X-Octo-Api-Token': OCTO_TOKEN //your token should be here
}
};
const setExtension = {
method: "PATCH",
url: '',
headers: {
'X-Octo-Api-Token': OCTO_TOKEN // your token should be here
},
data: {
extensions: ext,
bookmarks: [{ // here you can modify bookmarks which you want
"name": "google",
"url": "https://google.com"
},
{
"name": "facebook",
"url": "https://facebook.com"
}]
}
};
(async () => {
for (let i = 0; i < pagesNumber; i++) {
getProfiles.url = `${pageURL}${i}`;
const profilesUUID = await axios(getProfiles).catch(function (error) {
if (error.response.status === 429) {
console.log("Try after " + (error.response.headers['retry-after'] / 60) + " minutes");
} else {
console.log(error);
}
});
let rpm = profilesUUID.headers['x-ratelimit-remaining'];
let rph = profilesUUID.headers['x-ratelimit-remaining-hour'];
const profilesQuantity = profilesUUID.data.data.length;
if (rpm > 10 && rph > 10) {
for (let j = 0; j < profilesQuantity; j++) {
const uuid = profilesUUID.data.data[j].uuid;
setExtension.url = `${profilesURL}${uuid}`;
if (rpm < 5) {
console.log("waiting a minute");
await sleep(60000);
rpm += 200; //your rpm
}
if (rph < 5) {
console.log("waiting an hour...");
await sleep(3600000);
rph += 500; //your rph
}
const resp = await axios(setExtension).catch(function (error) {
console.log(error);
});
rpm = resp.headers['x-ratelimit-remaining'];
rph = resp.headers['x-ratelimit-remaining-hour'];
console.log(resp.data);
console.log('rph = ' + rph + ' rpm = ' + rpm);
}
} else {
console.log('Not enough RPM or RPH to proceed. RPM: ' + rpm + ', RPH: ' + rph);
}
}
})();
```
Prompt to convert the script to ChatGPT.

Let’s feed the snippets to ChatGPT.

Generated Python code for the Requests library
Expand
Sure, here's the equivalent Python script using the Requests library:

```python
import requests
import time
ext = ['aapfglkgnhmiaabhiijkjpfmhllaodgp@4.2.3'] # UUIDs of extensions
pageURL = 'https://app.octobrowser.net/api/v2/automation/profiles?page_len=100&page='
profilesURL = 'https://app.octobrowser.net/api/v2/automation/profiles/'
pagesNumber = 2 # 2 number of pages, you should check the number of your pages and modify it here(100 profiles on page maximum)
OCTO_TOKEN = "TOKEN" # token should be here
def sleep(ms):
time.sleep(ms / 1000.0)
getProfiles = {
"method": "GET",
"url": '',
"headers": {
'X-Octo-Api-Token': OCTO_TOKEN # your token should be here
}
}
setExtension = {
"method": "PATCH",
"url": '',
"headers": {
'X-Octo-Api-Token': OCTO_TOKEN # your token should be here
},
"data": {
"extensions": ext,
"bookmarks": [{ # here you can modify bookmarks as desired
"name": "google",
"url": "https://google.com"
},
{
"name": "facebook",
"url": "https://facebook.com"
}]
}
}
def main():
for i in range(pagesNumber):
getProfiles["url"] = f"{pageURL}{i}"
profilesUUID = requests.get(getProfiles["url"], headers=getProfiles["headers"])
if profilesUUID.status_code == 429:
print(f"Try after {profilesUUID.headers['retry-after']} seconds")
else:
rpm = int(profilesUUID.headers['x-ratelimit-remaining'])
rph = int(profilesUUID.headers['x-ratelimit-remaining-hour'])
profilesQuantity = len(profilesUUID.json()["data"])
if rpm > 10 and rph > 10:
for j in range(profilesQuantity):
uuid = profilesUUID.json()["data"][j]["uuid"]
setExtension["url"] = f"{profilesURL}{uuid}"
if rpm < 5:
print("waiting a minute")
sleep(60000)
rpm += 200 # your rpm
if rph < 5:
print("waiting an hour...")
sleep(3600000)
rph += 500 # your rph
resp = requests.patch(setExtension["url"], headers=setExtension["headers"], json=setExtension["data"])
rpm = int(resp.headers['x-ratelimit-remaining'])
rph = int(resp.headers['x-ratelimit-remaining-hour'])
print(resp.json())
print('rph = ' + str(rph) + ' rpm = ' + str(rpm))
else:
print('Not enough RPM or RPH to proceed. RPM: ' + str(rpm) + ', RPH: ' + str(rph))
if __name__ == "__main__":
main()
```
Please note that the "requests" library needs to be installed in your Python environment for this script to work. You can install it using pip:

```
pip install requests
```
Also, replace "TOKEN" with your actual token to make API requests.
Using ChatGPT to convert scripts

Using ChatGPT to convert scripts.

Working with Puppeteer, Selenium, and Playwright libraries

Browser automation frameworks are generally made to work well with Google Chrome, which is based on Chromium. As Octo Browser is built on the Chromium kernel too, it interacts with these frameworks seamlessly.

Automation with Selenium

Selenium is a popular tool for automating browser actions, as it allows to model user actions on a website.

Key features
  • Automation of web tasks.
  • Works with dynamic websites that use JavaScript and AJAX.
Advantages
  • Flexibility and support for many programming languages.
  • Free to use with a large and active community.
  • Open-source.
Disadvantages
  • Slow and resource-consuming.
  • You need a good understanding of programming concepts.

Browser automation with Selenium allows you to optimize different profile tasks ranging from simple automation scripts to web crawlers that search for, collect, and interact with data from different online resources.

Selenium is well-known by those who have experience managing several accounts at once. It can be deployed right in the browser, and it can be used to mimic actions of a real human. However, Selenium isn't always the perfect solution, and its masking can be detected by several platforms, CloudFlare among them.

You can use the nowsecure test website to check for automation detection. It is protected by CloudFlare, and if the page asks you to confirm that you are human, this means that the browser has not passed the check and automation was detected.
Successfully passing CloudFlare checks

Successfully passing CloudFlare checks.

Puppeteer automation

Puppeteer is a Node.js library that allows you to automate work with Chromium-based browsers using the DevTools protocol.

Features
  • Powerful and flexible web actions automation tool.
  • Can interact with webpages as a regular browser.
  • There is an unofficial Python port known as Pyppeteer, and we have created a guide on connecting it.
Advantages
  • A great choice for working with dynamic websites and executing JavaScript code.
  • An easy and intuitive API that is easy to use and configure.
  • A free tool with an active community.
Disadvantages
  • Only supports JavaScript (Node.js).
  • Resource-heavy; slower than some other libraries.

Puppeteer can bypass CloudFare defenses by running the Chrome DevTools protocol. However, mandatory use of Node.js makes this method less attractive.

There is a test website for Puppeteer browser automation detection that you might want to check out: https://pptr.dev

Playwright Automation

Playwright is a Node.js library that facilitates secure, quick and effective automation for Chromium, Firefox and WebKit using the same API.

Features
  • A code generation tool, CodeGen, is available. You can use it to avoid writing large amounts of repetitive code, which saves a lot of time.
  • You can slow down the speed of completing actions on a webpage by using the slowMo parameter, which brings the speed of completing these actions closer to real human values.
Advantages
  • Open source.
  • Easy to install and configure.
  • Supports all necessary browser engines.
  • Supports all three major OSs (macOS, Windows, Linux).
  • Supports all necessary programming languages (Python, Golang, Java, JS, C#).
  • Supports test runners (Mocha, Jest, Jasmine).
  • Integration with CI/CD tools (Jenkins, CircleCI, Azure Pipeline, TravisCI).
  • Automatic delays, so you don’t have to hard-code explicit delays.
  • The auto-wait function.
  • Parallel execution when you need to open multiple tabs simultaneously.
  • A comfortable Reporter.

Disadvantages
  • A relatively new product.
  • A relatively limited community.
  • No Ruby support.

API: Setting up the Environment

  1. Install Visual Studio Code to get started. Choose your OS and its type (32 or 64 bits).
  2. Install Node.js. Hit Enter twice during the installation to download additional packages in the PowerShell window.
  3. Create a new working folder in a convenient location. Open VS Code and press Ctrl + K + O, then select the folder you’ve just created.
  4. Install the NPM extension. It allows you to install packages for Node.js and ASP.NET Core and to control them. To do so, press Ctrl + P, and in the search window type ext install npm. Choose the first extension from the list that appears.
Installing the NPM extension in Visual Studio Code

Installing the NPM extension in Visual Studio Code.

5. Install the Code runner extension. To do so, press Ctrl + P, and in the search window type ext install code runner. Install the first extension from the list.
6. Open the VS Code terminal and initialize the folder using the command npm init -y. You will see the package.json file in the explorer and a corresponding message in the terminal.
7. Install the libraries using the command npm i axios puppeteer playwright in the VS Code terminal. You should see a new subfolder, node-modules, and a new file package-lock.json.

Useful snippets for multi-accounting in Octo Browser

You can use ready-made snippets from the Octo Browser API Knowledge Base, e.g., a ready-made script that adds a favorite proxy to a profile.
The script adds proxies to profiles
Expand
```
const axios = require('axios');
const data = {
proxy: {
uuid: 'uuidOfSavedProxy', //put UUID of saved proxy here
}
}
const config = {
method: 'patch',
url: 'https://app.octobrowser.net/api/v2/automation/profiles/uuidOfProfile', //Put UUID of profile
headers: {
'Content-Type': 'application/json',
'X-Octo-Api-Token': 'Token' //Put your Token here
},
data: data
};
axios(config)
.then(function (response) {
console.log(response.data);
})
.catch(function (error) {
console.log(error);
});
```

Creating and running the script

Create a .js file. Right-clicking on the Explorer will show you the created files. Go to the API documentation and select Node.js — Axios (usually cURL is the default option). You can launch the created script by running the command node script_name.js‎ in the VS Code terminal.
Automation in Octo Browser

Should I use automation for my team?

Our surveys indicate that more and more teams use automation, as it saves a lot of time and allows you to run independent and asynchronous processes with your profiles. Even a slight optimization of routine processes will produce tangible results and will greatly speed up your regular work in Octo Browser, rendering your work processes several times more effective. Using automation allows you to forget about configuring proxies manually, or adding start pages and necessary extensions to your profiles. You can use ready-made snippets from our Knowledge Base, or modify them for your precise needs to reach the new levels of multi-accounting.

FAQ:

I am worried that the script might steal my accounts, tokens, or passwords.
The code that we offer is both open and fully transparent. You can see for yourself that no requests to third-party resources are made, the script only uses official libraries, and is launched on your local machine.
Can I modify the script to better suit my needs?
Absolutely! This is open source, after all. We would be delighted if you use our scripts as the basic tweakable framework for your tasks.
Do Local API requests use up the available requests limit?
Of all the requests available in the Local API column, only the Start Profile requests count towards your limit. List Active Profiles, Stop Profile, Force Stop Profile, Login, Logout, Get Client Version, Update Client requests do not count towards your limit.
Can I create profiles in bulk while at the same time adding cookies, tags, and extensions to them?
Currently bulk profile creation with simultaneous cookie adding is, unfortunately, unavailable in the Octo Browser Client App itself. However, you can use our API for this. Choose a programming language that suits you best to create a script, and use a text file for cookies and other data. Make sure that the script is configured in such a way that the necessary parameters from the file are sent to profile creation requests sequentially.
Snippet is a small code fragment that performs particular well-defined tasks. You can copy and paste it into your main code, and then configure it further according to your precise needs.
Node, or Node.js, is a programming platform that executes JavaScript code outside the browser. It is built on the Chrome V8 engine.
Axios is a JavaScript library that allows making HTTP requests from the browser or Node.js.
CloudFlare is a web security service vendor that offers secure content delivery network services, protection from DDoS attacks, and DNS servers. Websites use CloudFare solutions to detect queries initiated by Selenium.
Python is a high-level programming language that is known for its efficiency, simplicity, and versatility.
Requests is a Python module that you can use to send all kinds of HTTP requests.

Stay up to date with the latest Octo Browser news

Related articles
Join Octo Browser now
Or contact the support team in chat for any questions, at any time.