CheshireCaat / playwright-with-fingerprints

Anonymous automation via playwright with fingerprint replacement technology.
MIT License
130 stars 9 forks source link

[Bug]: useProfile usage #56

Open Wizzzz opened 1 week ago

Wizzzz commented 1 week ago

Describe the bug Hello, I would like to use a profilte that I created later, but I got the following error:

stack: 'Error: “Custom IP information function” parameter is not a function.\n at C:\Us\***\Documents\dev_project\automation\\node_modules\browser-with-fingerprints\src\plugin\connector\index.js:55:15'

Code example carbon

Expected behavior stack: 'Error: “Custom IP information function” parameter is not a function.\n at C:\Us\***\Documents\dev_project\automation\\node_modules\browser-with-fingerprints\src\plugin\connector\index.js:55:15'

System (please complete the following information):

CheshireCaat commented 1 week ago

Can you please attach the proxy.txt file from your profile folder?

Wizzzz commented 1 week ago

It's pyproxy rotation proxy, i can send u email Username if u want try

CheshireCaat commented 1 week ago

I don't need to check the proxy itseld, it would be better to check the file - you can send it to the mail likangt2012@gmail.com. Or write what value the ip_info_method parameter has in the file inside your profile.

Wizzzz commented 1 week ago

Oh my bad

the content:

{ "server": "**", "Port": "**", "IsHttp": true, "name": "**", "password": "**", "DetectExternalIp": true, "ChangeGeolocation": true, "ChangeWebrtcIp": true, "ChangeTimezone": true, "ChangeBrowserLanguage": true, "ip_info_method": "database", "ip_api_key": "", "ServiceURL": "", "IpExtractionParam": "", "IpExtractionMethod": "raw" }

CheshireCaat commented 1 week ago

I can't reproduce the problem. Please attach the code example that causes the bug.

Wizzzz commented 1 week ago

I'll make a sample code with the profile and proxy that I'll email to you. But I was wondering, isn't there a way to launch the profile by hand? Because basically what I want to do is generate profiles with playwirhgt-with-fingerprints but in the future I want to use the profile by hand. Is the only way to reuse the profile to use the package or can I do it directly without?

CheshireCaat commented 1 week ago

You probably can try to use profile, for example, in default chromium browser, but in this case there will be no way to use proxy and fingerprint.

Wizzzz commented 1 week ago

Ah well, I'd like to have proxy and fingerprint, I'll email you my sample code.

CheshireCaat commented 1 week ago

By the way, there is an option to use profiles manually, but you need a service key for this. There is a separate FingerprintManager application that allows you to work with profiles manually. It probably should correctly work with profiles from this plugin.

Wizzzz commented 1 week ago

But it's perfect, just what I needed. Thank you very much.

However, I've just done a test, but when I create my profile with playwright-with-fingerprints, create the account on the site and open fingerprintmanager, my account is no longer connected.

Doesn't profile generation store history/cookies/localstorage?

CheshireCaat commented 1 week ago

I think this is possible due to the difference in browser versions, try using the same versions. For example, I have now tried to install the 128 version for the plugin and use the same one in the manager - the sessions work correctly:

plugin.useBrowserVersion('128.0.6613.85');
Wizzzz commented 1 week ago

I just did the following code but it doesn't work either, I'm not logged in when I open fingerprint manager :

const device = {
    tags : this.instanceOptions.browserOptions.tags || [“Microsoft Windows”, “Chrome”],
    timeLimit : “ 15 days ”,
} ;

// retrieve fingerprint
plugin.setServiceKey(this.instanceOptions.browserOptions.fingerprintSwitcherKey) ;
const fingerprint = await plugin.fetch(device) ;
const args = this.instanceOptions.browserOptions.args || [] ;
plugin.useFingerprint(fingerprint) ;
plugin.useBrowserVersion("128.0.6613.85”) ;
await plugin.launchPersistentContext(this.instanceOptions.browserOptions.profilePath, {
    key : this.instanceOptions.browserOptions.fingerprintSwitcherKey,
    headless : this.instanceOptions.browserOptions.headless,
    args,
}) ;

Yet I'm closing with the browser's close method, maybe that's why?

CheshireCaat commented 1 week ago
  1. It's not critical, but it's better to change browser version for plugin before all logic (fetch and launch).
  2. How do you add a profile to the manager? Are you transferring it to a folder with profiles?
Wizzzz commented 1 week ago

So I couldn't find a button on the gui to import a profile, so I made a copy of my folder generated by playwright-with-fingerprints in the BASProfileManager folder.

CheshireCaat commented 1 week ago

It's should be OK, what version of FM did you use?

Wizzzz commented 1 week ago

The last one I've just installed.

CheshireCaat commented 1 week ago

I'm unable to reproduce the problem, here is my code:

import path from 'path';
import { plugin } from 'playwright-with-fingerprints';
import { SERVICE_KEY, WORKING_FOLDER } from './config.js';

const profile = path.resolve('./profile');

plugin.setServiceKey(SERVICE_KEY);
plugin.setWorkingFolder(WORKING_FOLDER);
plugin.useBrowserVersion('128.0.6613.85');

plugin.useProfile(profile, {
  loadFingerprint: true,
  loadProxy: true,
});

await plugin.launchPersistentContext(profile, { headless: false });

I log in, close the browser, then move the profile folder to the FM profiles folder, launch the program, open the profile and everything works correctly.

Wizzzz commented 1 week ago

It's really strange, I can't figure out what's going on, here's my full code and I can't figure out what I'm doing wrong.

My procedure for testing is to open the browser with my code, connect by hand to a gmail account, press enter to close the browser and go to fm to open the profile.

Except that when I arrive on the profile with Fm, well I'm on google.com but not connected :(

require("dotenv").config();

const { plugin } = require("playwright-with-fingerprints");
const key = process.env.FINGERPRINT_KEY;
const path = require("path");
const profilePath = path.resolve("C:\\Users\\Admin\\AppData\\Local\\BASProfileManager\\myprofile");
const pathToEngine = path.resolve("C:\\Users\\Admin\\Documents\\dev_project\\automation\\automation-aio\\data");
const readline = require("readline");

(async () => {
    plugin.setServiceKey(key);
    plugin.useBrowserVersion("128.0.6613.85");
    plugin.setWorkingFolder(pathToEngine);

    plugin.useProfile(profilePath, {
        loadFingerprint: true,
        loadProxy: true,
    });

    const browser = await plugin.launchPersistentContext(profilePath, {
        key,
        headless: false,
    });
    await browser.newPage();

    console.log("Press enter to close");
    const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout,
    });

    rl.on("line", async () => {
        console.log("Close browser ...");
        await browser.close();
        rl.close();
    });
})();
CheshireCaat commented 1 week ago

@Wizzzz how did you check that you are not connected?

I just tried your code:

  1. My account appeared on the Google homepage after restarting the code and opening the profile inside FM.
  2. After opening the Gmail website I saw this:

image

  1. I just pressed the Login button and everything is fine:

image

Wizzzz commented 1 week ago

Here's a demonstration of how to use the code:

https://youtu.be/Z5uBrJ368HM

CheshireCaat commented 1 week ago

You should use FingerprintManager3, judging by your video, you are using an old version - it uses a very old browser version, and the version of the engine itself is also outdated.

You can find the latest version here.

Wizzzz commented 1 week ago

Oh dear, I used the link available in the bablosoft forum, I didn't know there was another link on the profile.

Indeed now it works better, thank you very much and really sorry for the inconvenience

CheshireCaat commented 1 week ago

@Wizzzz great, will wait for your ticket-related example.