gologin-commonjs 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,25 @@
1
+ ```
2
+ const GoLogin = require("gologin-commonjs");
3
+
4
+ const token = "your_token";
5
+ const profile_id = "your_profile_id";
6
+
7
+ (async () => {
8
+ const GL = new GoLogin({
9
+ token,
10
+ profile_id,
11
+ });
12
+
13
+ try {
14
+ const gologin = await GL.start();
15
+
16
+ const browser = await puppeteer.connect({
17
+ browserWSEndpoint: gologin.wsUrl.toString(),
18
+ ignoreHTTPSErrors: true,
19
+ });
20
+
21
+ const page = await browser.newPage();
22
+ await page.goto("https://youtube.com");
23
+ } catch {}
24
+ })();
25
+ ```
@@ -222,9 +222,9 @@ class GoLogin {
222
222
  }
223
223
  async emptyProfileFolder() {
224
224
  debug('get emptyProfileFolder');
225
- const currentDir = (0, _path.dirname)(new URL(require('url').pathToFileURL(__filename).toString()).pathname);
225
+ const currentDir = (0, _path.dirname)(__filename);
226
226
  const zeroProfilePath = (0, _path.join)(currentDir, '..', 'zero_profile.zip');
227
- const profile = await readFile((0, _path.resolve)(zeroProfilePath));
227
+ const profile = await readFile(zeroProfilePath);
228
228
  debug('emptyProfileFolder LENGTH ::', profile.length);
229
229
  return profile;
230
230
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gologin-commonjs",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A CommonJS Transpiled GoLogin API",
5
5
  "types": "./types/gologin.d.ts",
6
6
  "main": "./dist/src/gologin.js",
package/tes.js CHANGED
@@ -1,8 +1,9 @@
1
- const GoLogin = require('./dist/src/gologin')
1
+ const GoLogin = require("./dist/src/gologin");
2
+ // you can use declaration below in your project
3
+ // const GoLogin = require("gologin-commonjs");
2
4
 
3
-
4
- const token = 'your_token';
5
- const profile_id = 'your_profile_id';
5
+ const token = "your_token";
6
+ const profile_id = "your_profile_id";
6
7
 
7
8
  (async () => {
8
9
  const GL = new GoLogin({
@@ -10,26 +11,15 @@ const profile_id = 'your_profile_id';
10
11
  profile_id,
11
12
  });
12
13
 
13
- const { status, wsUrl } = await GL.start().catch((e) => {
14
- console.trace(e);
15
-
16
- return { status: 'failure' };
17
- });
18
-
19
- if (status !== 'success') {
20
- console.log('Invalid status');
21
-
22
- return;
23
- }
14
+ try {
15
+ const gologin = await GL.start();
24
16
 
25
- const browser = await puppeteer.connect({
26
- browserWSEndpoint: wsUrl.toString(),
27
- ignoreHTTPSErrors: true,
28
- });
17
+ const browser = await puppeteer.connect({
18
+ browserWSEndpoint: gologin.wsUrl.toString(),
19
+ ignoreHTTPSErrors: true,
20
+ });
29
21
 
30
- const page = await browser.newPage();
31
- await page.goto('https://youtube.com');
32
- // console.log(await page.content());
33
- // await browser.close();
34
- // await GL.stop();
35
- })();
22
+ const page = await browser.newPage();
23
+ await page.goto("https://youtube.com");
24
+ } catch {}
25
+ })();