You can find your API token in the Additional settings of your Octo Browser Master Account
//modules
const axios = require('axios');
//here is config. Paste your Octo API Token here and you can modify this for your personal needs
const config = {
octo_token: "OCTO_API_TOKEN",
octo_api_base_url: "https://app.octobrowser.net/api/v2/automation/",
data: {
extensions: ['aapfglkgnhmiaabhiijkjpfmhllaodgp@4.2.3'],
bookmarks: [{ "name": "google", "url": "https://google.com" }, { "name": "facebook", "url": "https://facebook.com" }],
start_pages: ["https://google.com", "https://facebook.com"]
}
}
const OCTO_REMOTE_API = axios.create({
baseURL: config.octo_api_base_url,
timeout: 10000,
headers: {
'X-Octo-Api-Token': config.octo_token,
'Content-Type': "application/json"
}
});
//functions
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms * 1000));
}
async function check_limits(response) {
let rpm = response.headers['x-ratelimit-remaining'];
let rph = response.headers['x-ratelimit-remaining-hour'];
if (rpm < 10) {
console.log("Waiting a minute...");
await sleep(60);
}
if (rph < 10) {
console.log("Waiting an hour...");
await sleep(3600);
}
}
async function get_total_profiles(){
const response = await OCTO_REMOTE_API.get('/profiles?page=0&page_len=10');
const total_profiles = response.data.total_count;
const total_pages = Math.ceil(response.data.total_count/100);
console.log(`Total Profiles: ${total_profiles}\nTotal Pages: ${total_pages}`);
await check_limits(response);
return total_pages;
}
async function get_all_profiles_uuids(total_pages){
let profiles = [];
for (let i = 0; i < total_pages; i++) {
let response = await OCTO_REMOTE_API.get(`/profiles?page=${i}&page_len=100`);
await check_limits(response);
profiles.push(...response.data.data);
}
return profiles;
}
async function patch_all_profiles(profiles){
let updated = [];
let not_updated = [];
for (let profile of profiles) {
try{
const response = await OCTO_REMOTE_API.patch(`/profiles/${profile.uuid}`, config.data);
await check_limits(response);
updated.push(profile);
console.log(`Successfully updated ${profile.uuid}`);
} catch (error) {
not_updated.push(profile);
console.error(`ERROR: Can't patch profile ${profile.uuid}`);
}
}
return [updated, not_updated];
}
//main process
(async () => {
const total = await get_total_profiles();
const profiles = await get_all_profiles_uuids(total);
const [updated, not_updated] = await patch_all_profiles(profiles);
console.log(`Finished process:\nUpdated: ${updated.length}\nNot updated: ${not_updated.length}`);
})();
Let’s feed the snippets to ChatGPT
import requests
import math
import time
# Config
config = {
"octo_token": "OCTO_API_TOKEN",
"octo_api_base_url": "https://app.octobrowser.net/api/v2/automation/",
"data": {
"extensions": ["aapfglkgnhmiaabhiijkjpfmhllaodgp@4.2.3"],
"bookmarks": [
{"name": "google", "url": "https://google.com"},
{"name": "facebook", "url": "https://facebook.com"}
],
"start_pages": ["https://google.com", "https://facebook.com"]
}
}
# Session setup
session = requests.Session()
session.headers.update({
"X-Octo-Api-Token": config["octo_token"],
"Content-Type": "application/json"
})
session.timeout = 10
# Helper functions
def sleep(seconds):
time.sleep(seconds)
def check_limits(response):
rpm = int(response.headers.get("x-ratelimit-remaining", 0))
rph = int(response.headers.get("x-ratelimit-remaining-hour", 0))
if rpm < 10:
print("Waiting a minute...")
sleep(60)
if rph < 10:
print("Waiting an hour...")
sleep(3600)
# API functions
def get_total_profiles():
response = session.get(f"{config['octo_api_base_url']}profiles?page=0&page_len=10")
response.raise_for_status()
total_profiles = response.json()["total_count"]
total_pages = math.ceil(total_profiles / 100)
print(f"Total Profiles: {total_profiles}\nTotal Pages: {total_pages}")
check_limits(response)
return total_pages
def get_all_profiles_uuids(total_pages):
profiles = []
for i in range(total_pages):
response = session.get(f"{config['octo_api_base_url']}profiles?page={i}&page_len=100")
response.raise_for_status()
check_limits(response)
profiles.extend(response.json()["data"])
return profiles
def patch_all_profiles(profiles):
updated = []
not_updated = []
for profile in profiles:
try:
response = session.patch(
f"{config['octo_api_base_url']}profiles/{profile['uuid']}",
json=config["data"]
)
response.raise_for_status()
check_limits(response)
updated.append(profile)
print(f"Successfully updated {profile['uuid']}")
except Exception as e:
not_updated.append(profile)
print(f"ERROR: Can't patch profile {profile['uuid']} - {str(e)}")
return updated, not_updated
# Main process
if __name__ == "__main__":
try:
total = get_total_profiles()
profiles = get_all_profiles_uuids(total)
updated, not_updated = patch_all_profiles(profiles)
print(f"Finished process:\nUpdated: {len(updated)}\nNot updated: {len(not_updated)}")
except Exception as e:
print(f"Fatal error: {str(e)}")
pip install requests
Using ChatGPT to convert scripts
Installing the NPM extension in Visual Studio Code
//connecting modules
const fs = require('fs').promises;
const axios = require('axios');
//here is config. Paste your Octo API Token here
const config = {
octo_token: "OCTO_API_TOKEN",
octo_api_base_url: "https://app.octobrowser.net/api/v2/automation/",
}
const OCTO_REMOTE_API = axios.create({
baseURL: config.octo_api_base_url,
timeout: 10000,
headers: {
'X-Octo-Api-Token': config.octo_token,
'Content-Type': "application/json"
}
});
//functions
async function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms * 1000));
}
async function check_limits(response) {
let rpm = response.headers['x-ratelimit-remaining'];
let rph = response.headers['x-ratelimit-remaining-hour'];
if (rpm < 10) {
console.log("Waiting a minute...");
await sleep(60);
}
if (rph < 10) {
console.log("Waiting an hour...");
await sleep(3600);
}
}
async function get_total_pages() {
const response = await OCTO_REMOTE_API.get('/profiles?page=0&page_len=10');
const total_profiles = response.data.total_count;
const total_pages = Math.ceil(response.data.total_count / 100);
console.log(`Total Profiles: ${total_profiles}\nTotal Pages: ${total_pages}`);
await check_limits(response);
return total_pages;
}
async function get_all_profiles_titles(total_pages) {
let profiles = [];
for (let i = 0; i < total_pages; i++) {
let response = await OCTO_REMOTE_API.get(`/profiles?page=${i}&page_len=100&fields=title`);
await check_limits(response);
profiles.push(...response.data.data);
}
return profiles;
}
async function write_file(profiles) {
const titles = profiles.map(item => item.title).filter(Boolean);
try {
await fs.writeFile('./profiles_titles.txt', titles.join('\n'), 'utf-8');
} catch (error) {
console.error(`ERROR: While trying writing the file some error occured:\n${error}`);
}
}
//main process
(async () => {
const total_pages = await get_total_pages();
const profiles = await get_all_profiles_titles(total_pages);
await write_file(profiles);
console.log('Finished. Check profiles_titles.txt file...');
})()