npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cloak-stealth

v1.5.3

Published

A high-level API to control Orbita browser over Cloak API

Downloads

544

Readme

Cloak Stealth (Comming soon) Contact me on Telegram

Cloak Stealth is a powerful browser automation library that allows you to manage browser profiles, control proxy settings, and perform various browser-related tasks with advanced fingerprinting protection.

Installation

ES Modules

If you're using ES modules, you can import the package like this:

import CloakStealth from 'cloak-stealth';

// Use the package
const cloak = new CloakStealth();
// ... rest of your code

CommonJS

If you're using CommonJS, you can require the package like this:

const CloakStealth = require('cloak-stealth');

// Use the package
const cloak = new CloakStealth();
// ... rest of your code

Features

  • Create and manage browser profiles with customizable settings
  • Advanced proxy configuration with rotation and batch assignment
  • Customize browser fingerprints (user agent, resolution, canvas, WebGL, etc.)
  • Run automated tasks across multiple profiles concurrently
  • Handle bookmarks and other browser data
  • Manage browser connections efficiently
  • Bypass Cloudflare protection (optional)
  • Support for various operating systems and device types

Usage

Importing the library

    import { CloakAPIManager, CloakAPIOptions, ProfileCreationOptions, ProxyConfig, BrowserConnection } from 'cloak-stealth';

Creating a CloakAPIManager instance

    const options: CloakAPIOptions = {
      apiKey: "lsk_8eb27803a3ada31587b0f125328b25f7eb4f47xxxxxxxx",
      currentDir: '/path/to/working/directory',
      browsersDir: '/path/to/browser/profiles',
      extensions: ['/path/to/extensions', '/path/to/extensions'],
      windowOptions: { cols: 1280, rows: 720 },
      clearCacheAndHistory: true,
      turnstile: false,
      advancedStealthMode: false,
      proxyConfig: {
        type: 'rotate',
        proxies: ['ip1:port1:user1:pass1', 'ip2:port2:user2:pass2'],
        proxyMode: 'http'
      }
    };
    
    const manager = new CloakAPIManager(options);

Profile Management

Creating a single profile

    const profileOptions: ProfileCreationOptions = {
      name: 'MyProfile',
      os: 'win',
      audioContext: {
         mode: "noise",
      },
      canvas: {
        mode: "off",
      },
      webGL: {
        mode: "off",
      },
      webGLMetadata: {
        mode: "noise",
      },
      navigator: {
        userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
        resolution: '1920x1080',
        language: 'en-US',
        platform: 'Win32',
        hardwareConcurrency: 8,
        deviceMemory: 8
      },
      googleServicesEnabled: true,
      lockEnabled: false
    };
    
    const profileId = await manager.create(profileOptions);
    console.log('Created profile:', profileId);

Quick create multiple profiles

    const profileIds = await manager.quickCreateMultipleProfiles(5, 'BatchProfile', 1000, {
      os: 'lin',
      navigator: {
        resolution: '1366x768'
      }
    });
    console.log('Created profiles:', profileIds);

Checking if a profile exists

    const exists = await manager.profileExists('profile-id');
    console.log('Profile exists:', exists);

Getting all profiles

    const allProfiles = await manager.getAllProfiles(1,10);
    console.log('All profiles:', allProfiles);

Deleting profiles

    // Delete a single profile
    const result = await manager.delete('profile-id');
    console.log('Deletion result:', result);

    // Delete specific profiles
    const specificResults = await manager.deleteAllProfiles(['profile-id-1', 'profile-id-2', 'profile-id-3']);
    console.log('Specific deletion results:', specificResults);

    // Delete all profiles
    const results = await manager.deleteAllProfiles();
    console.log('Deletion results:', results);

Browser Automation

Starting a browser session

    const connection = await manager.start({ profileId: 'your-profile-id' });
    if (connection) {
      const { browser, page } = connection;
      await page.goto('https://example.com');
      // Perform other actions...
      await manager.closeProfile(connection);
    }

Running automation on all profiles

    const automationFunction = async (connection: BrowserConnection, index: number) => {
      const { page } = connection;
      await page.goto('https://example.com');
      // Perform actions...
      const title = await page.title();
      console.log(`Page ${index} title:`, title);
    };
    
    await manager.runAllProfiles(automationFunction, { 
      threads: 5, 
      startIndex: 0, 
      endIndex: 10, 
      delay: 1000,
      autoClose: true
    });

Proxy Configuration

Changing proxy for a profile

    await manager.changeProfileProxy('profile-id', {
      mode: 'http',
      host: 'proxy.example.com',
      port: 8080,
      username: 'user',
      password: 'pass'
    });

Rotating proxies

    const rotateConfig: ProxyConfig = {
      type: 'rotate',
      proxies: ['ip1:port1:user1:pass1', 'ip2:port2:user2:pass2'],
      proxyMode: 'http'
    };
    
    // Use this config when creating the CloakAPIManager instance

Batch proxy assignment

    const batchConfig: ProxyConfig = {
      type: 'batch',
      proxies: ['ip1:port1:user1:pass1', 'ip2:port2:user2:pass2'],
      batchSize: 5,
      proxyMode: 'http'
    };
    
    // Use this config when creating the CloakAPIManager instance
    

Fingerprint Customization

Changing resolution

    await manager.changeProfileResolution('profile-id', { width: 1920, height: 1080 });

Changing user agent

    await manager.changeProfileUserAgent('profile-id', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36');

Setting timezone

    const success = await manager.setProfileTimezone('profile-id', 'America/New_York');
    console.log('Timezone set:', success);

Bookmarks Management

    // Get all bookmarks
    const bookmarks = await manager.getBookmarks('profile-id');
    console.log('Bookmarks:', bookmarks);
    
    // Add a bookmark
    await manager.addBookmark('profile-id', {
      title: 'Example',
      url: 'https://example.com'
    });
    
    // Remove a bookmark
    await manager.removeBookmark('profile-id', 'bookmark-id');

Cleaning Up

    // Exit a specific browser
    await manager.closeBrowser(browserConnection);
    
    // Exit all browsers
    await manager.exitAllBrowsers();
    
    // Exit the CloakAPIManager instance
    await manager.exit();
    
    // Exit all CloakAPIManager instances
    await exitAll();

Advanced Usage

Custom Automation with Error Handling

    const customAutomation = async (connection: BrowserConnection) => {
      const { page } = connection;
      try {
        await page.goto('https://example.com');
        const element = await page.waitForSelector('#specific-element', { timeout: 5000 });
        if (element) {
          await element.click();
          // Perform more actions...
        }
      } catch (error) {
        console.error('Automation error:', error);
      }
    };
    
    await manager.start({ 
      profileId: 'your-profile-id',
      skipCheckBrowser: true
    }, customAutomation);

Proxy Rotation with Retries

    const rotateProxyAutomation = async (connection: BrowserConnection, index: number) => {
      const { page } = connection;
      let retries = 3;
      while (retries > 0) {
        try {
          await page.goto('https://example.com');
          // If successful, break the loop
          break;
        } catch (error) {
          console.error(`Error on attempt ${4 - retries}:`, error);
          retries--;
          if (retries > 0) {
            // Rotate to next proxy
            await manager.assignProxyToProfile(connection.profileId, index + 1);
          }
        }
      }
    };
    
    await manager.runAllProfiles(rotateProxyAutomation, { threads: 3 });

Troubleshooting

  • Proxy Connection Issues: Ensure your proxy settings are correct and the proxies are active. Try using a different proxy or temporarily disabling proxy to isolate the issue.

  • Fingerprinting Detection: If websites are detecting your automated activity, try adjusting the noise settings for canvas, WebGL, and audio context. You may also need to randomize your user agent and other navigator properties more frequently.

  • Performance Issues: If you're running many profiles concurrently, try reducing the number of threads or increasing the delay between actions to reduce resource usage.

  • Bypass Turnstile: Automatically check and bypass Turnstile by ensuring the turnstile option is set to true. If issues persist, consider implementing additional strategies or using specialized services designed for this purpose.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License