gadisk820 commited on
Commit
6835239
·
verified ·
1 Parent(s): 15ff154

Upload login_browser.js

Browse files
Files changed (1) hide show
  1. app/login_browser.js +67 -0
app/login_browser.js ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // login_browser.js
2
+ const fs = require('fs');
3
+ const puppeteer = require('puppeteer');
4
+ const interstitial = require('./interstitial'); // modul CF yang kamu punya
5
+
6
+ const [email, password, sitekey, cookieFile] = process.argv.slice(2);
7
+
8
+ (async () => {
9
+ const browser = await puppeteer.launch({
10
+ headless: true,
11
+ args: ['--no-sandbox', '--disable-setuid-sandbox']
12
+ });
13
+
14
+ const page = await browser.newPage();
15
+ await page.setUserAgent('Mozilla/5.0 (Linux; Android 12; Chrome/143 Mobile)');
16
+
17
+ // buka login page
18
+ await page.goto('https://makeyoutask.com/login', { waitUntil: 'domcontentloaded' });
19
+
20
+ // tunggu form login
21
+ await page.waitForSelector('input[name="email"]');
22
+
23
+ // isi login
24
+ await page.type('input[name="email"]', email);
25
+ await page.type('input[name="password"]', password);
26
+
27
+ // solve Turnstile
28
+ const token = await (async () => {
29
+ const resp = await fetch(`https://gi2h-makeyourtask.hf.space/solve`, {
30
+ method: 'POST',
31
+ headers: { 'Content-Type': 'application/json' },
32
+ body: JSON.stringify({
33
+ key: '00000000000000000000#0000000000000000000#000000000000000000#',
34
+ type: 'turnstile',
35
+ sitekey,
36
+ domain: 'https://makeyoutask.com/login'
37
+ })
38
+ });
39
+ const data = await resp.json();
40
+ return data.token || '';
41
+ })();
42
+
43
+ await page.evaluate(`document.querySelector('input[name="cf-turnstile-response"]').value='${token}'`);
44
+
45
+ // submit form
46
+ await Promise.all([
47
+ page.click('button[type="submit"]'),
48
+ page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 15000 }).catch(() => {})
49
+ ]);
50
+
51
+ // check if CF interstitial
52
+ if (page.url().includes('cdn-cgi/challenge-platform') || page.url().includes('Just a moment')) {
53
+ const cf = await interstitial({ domain: 'https://makeyoutask.com', proxy: null }, page);
54
+ if (cf?.cookies) {
55
+ fs.writeFileSync(cookieFile, cf.cookies.join('\n'));
56
+ console.log('[CF] clearance saved');
57
+ }
58
+ } else {
59
+ // ambil cookie biasa
60
+ const cookies = await page.cookies();
61
+ const cookieLines = cookies.map(c => `${c.domain}\tTRUE\t${c.path}\t${c.secure}\t${c.expires}\t${c.name}\t${c.value}`);
62
+ fs.writeFileSync(cookieFile, cookieLines.join('\n'));
63
+ console.log('[LOGIN] cookies saved');
64
+ }
65
+
66
+ await browser.close();
67
+ })();