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

tdgologin

v2.0.2

Published

Bản mod gologin cho goloin

Downloads

1

Readme

FILE package.json chính của tool phải thêm đoạn : "type": "module",

Phiên bản mới cần sửa :

async start() {
  if (this.is_remote) {
    return this.startRemote();
  }

  if (!this.executablePath) {
    await this.checkBrowser();
  }

  const ORBITA_BROWSER = this.executablePath || this.browserChecker.getOrbitaPath;

  const orbitaBrowserExists = await access(ORBITA_BROWSER).then(() => true).catch(() => false);
  if (!orbitaBrowserExists) {
    throw new Error(`Orbita browser is not exists on path ${ORBITA_BROWSER}, check executablePath param`);
  }

  await this.createStartup();
  // await this.createBrowserExtension();



  // const wsUrl = await this.spawnBrowser();



  
  this.setActive(true);

  // return { status: 'success', wsUrl };
  return { status: 'success' };
}
const wsUrl = await this.spawnBrowser();
import * as path from 'path';
import Gologin from 'tdgologin';

class Glogin {
    constructor(tokenApi, pathFolderProfiles) {
        this.token = tokenApi;
        this.tmpdir = pathFolderProfiles;
    }
    async newProfile(os, profileName, userAgent) {
        const GL = new Gologin({
            token: this.token,
            tmpdir: this.tmpdir,
        });
        if (os == "win" || os == "mac" || os == "lin") {
            var windows_sizes = ["1152x648", "1152x864", "1280x720", "1280x768", "1280x800", "1280x960", "1280x1024", "1360x768", "1366x768", "1400x1050", "1440x900", "1440x1080", "1536x864", "1600x900", "1600x1200", "1680x1050", "1856x1392", "1920x1080", "1920x1200", "1920x1440"];
        } else {
            var windows_sizes = ["393x873", "360x760", "384x832", "384x854", "412x915", "393x851", "384x896", "412x892"];
        }
        // Lấy số ngẫu nhiên trong khoảng từ 0 đến độ dài của mảng
        var randomIndex = Math.floor(Math.random() * windows_sizes.length);
        // Lấy phần tử ngẫu nhiên từ mảng
        var windows_size = windows_sizes[randomIndex];
        const profile_id = await GL.create({
            'name': profileName,
            'os': os, // 'win', 'lin', 'android'
            // isM1: true, // for Mac M1
            'navigator': {
                'autoLang': true,
                'language': 'en-US,en;q=0.9',
                'userAgent': userAgent, // get random user agent for selected os
                'resolution': windows_size,
            },
            'audioContext': {
                "mode": "noise",
                "noise": 0
            },
            'canvas': {
                "mode": "noise",
                "noise": 0
            },
            'webGL': {
                "mode": "noise",
                "getClientRectsNoise": 0,
                "noise": 0
            },
            'clientRects': {
                "mode": "noise",
                "noise": 0
            },
            'timezone': {
                "enabled": true,
                "fillBasedOnIp": true,
                "timezone": "string"
            },
            'proxyEnabled': false,
            'proxy': {
                'mode': 'none',
            },
        });

        console.log('profile id=', profile_id);

        await GL.update({
            'id' : profile_id,
            'name' : 'profile_mac2',
        });
        return profile_id;
    }

    async downloadProfile(profile_id) {
        const GL = new Gologin({
            token: this.token,
            tmpdir: this.tmpdir,
            profile_id: profile_id,
        });
        try {
            const { status } = await GL.start();
            if (status !== 'success') {
                return false;
            } else {
                const pathProfile =  path.join(this.tmpdir, 'gologin_profile_'+profile_id);
                const pathProfileZip =  path.join(this.tmpdir, 'gologin_'+profile_id+'.zip');
                return {'pathProfile' :  pathProfile, 'pathProfileZip' : pathProfileZip};
            }
        } catch (error) {
            return false;
        }
    }

    async getProfileOffline(os, profileName, userAgent) {
        const profileId = await this.newProfile(os, profileName, userAgent);
        const profilePaths = await this.downloadProfile(profileId);
        return profilePaths;
    }
}



// cách dùng
const apiKey = "xxxxxxxxxxx";
const pathProfiles = "C:\\Users\\TDev\\Desktop\\testp";
const os = "win";
const profileName = "WIn_Abc";
const userAgent = "random";


const gloginInstance = new Glogin(apiKey, pathProfiles);
(async () => {
    const profilePaths = await gloginInstance.getProfileOffline(os, profileName, userAgent);
    console.log(profilePaths);
})();