Reaperxxxx commited on
Commit
610699d
Β·
verified Β·
1 Parent(s): c91735f

Update app.js

Browse files
Files changed (1) hide show
  1. app.js +126 -65
app.js CHANGED
@@ -106,7 +106,7 @@ function loadCookies(cookieFilePath) {
106
  }
107
 
108
  const browser = await puppeteer.launch({
109
- headless: true,
110
  args: [
111
  '--no-sandbox',
112
  '--disable-setuid-sandbox',
@@ -231,20 +231,30 @@ function loadCookies(cookieFilePath) {
231
 
232
  // First, navigate to the domain to establish context
233
  try {
234
- await page.goto('https://m.betking.com/', {
 
235
  waitUntil: 'domcontentloaded',
236
  timeout: 15000
237
  });
238
- console.log('βœ“ Base domain loaded');
239
 
240
  // Wait a bit for any Cloudflare JS to run
241
  await wait(3000);
242
  } catch (baseError) {
243
- console.log('⚠️ Base domain load issue, trying alternative...');
244
- // Try setting domain manually
245
- await page.evaluateOnNewDocument(() => {
246
- document.domain = 'betking.com';
247
- });
 
 
 
 
 
 
 
 
 
248
  }
249
 
250
  // Now set all cookies
@@ -476,10 +486,13 @@ function loadCookies(cookieFilePath) {
476
  console.log('\n🌐 Navigating to the page...');
477
  await randomWait(500, 1500);
478
 
479
- // Navigate to the actual target URL
 
 
 
480
  let response;
481
  try {
482
- response = await page.goto('https://m.betking.com/en-ng?', {
483
  waitUntil: ['domcontentloaded', 'networkidle2'],
484
  timeout: 45000
485
  });
@@ -698,8 +711,8 @@ function loadCookies(cookieFilePath) {
698
  }
699
  }
700
 
701
- console.log('\n⏳ Waiting 3 seconds...');
702
- await wait(3000);
703
 
704
  // Take initial screenshot
705
  console.log('\nπŸ“Έ Taking initial screenshot...');
@@ -708,69 +721,117 @@ function loadCookies(cookieFilePath) {
708
  fullPage: true
709
  });
710
 
711
- console.log('\nπŸ” Looking for the Sign In button...');
712
-
713
- const buttonSelectors = [
714
- 'button[data-testid="signInButton"]',
715
- 'button#signInButton',
716
- 'button.pill.pill-text.pill-text--inherit.pill--medium.button'
717
- ];
718
 
719
- let buttonFound = false;
720
- let buttonSelector = null;
721
-
722
- for (const selector of buttonSelectors) {
723
- try {
724
- const button = await page.$(selector);
725
- if (button) {
726
- buttonFound = true;
727
- buttonSelector = selector;
728
- console.log(`βœ“ Button found using selector: ${selector}`);
729
-
730
- const isVisible = await button.isIntersectingViewport();
731
- console.log(`Button is visible: ${isVisible}`);
732
-
733
- if (isVisible) {
734
- console.log('πŸ‘† Clicking the button...');
735
- await randomWait(200, 800);
736
- await button.click();
737
- console.log('βœ“ Button clicked successfully!');
738
- } else {
739
- console.log('Button exists but is not visible, scrolling into view...');
740
- await page.evaluate((sel) => {
741
- document.querySelector(sel).scrollIntoView({ behavior: 'smooth', block: 'center' });
742
- }, selector);
743
- await wait(500);
744
- await randomWait(200, 800);
745
- await button.click();
746
- console.log('βœ“ Button clicked after scrolling!');
747
  }
748
-
749
- await wait(1500);
750
- break;
 
 
 
751
  }
752
- } catch (error) {
753
- console.log(`Selector ${selector} failed: ${error.message}`);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
754
  }
 
 
755
  }
756
 
757
- if (!buttonFound) {
758
- console.log('⚠️ Button not found with any selector.');
759
- console.log('This might mean you\'re already logged in or the page structure changed.');
760
-
761
- const allButtons = await page.evaluate(() => {
762
- return Array.from(document.querySelectorAll('button')).slice(0, 20).map(btn => ({
763
- id: btn.id,
764
- class: btn.className,
765
- text: btn.innerText?.substring(0, 50),
766
- testId: btn.getAttribute('data-testid')
767
- }));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
768
  });
769
- console.log('\nπŸ“‹ Available buttons on page (first 20):');
770
- console.log(JSON.stringify(allButtons, null, 2));
 
 
 
 
 
 
771
  }
772
 
773
  console.log('\nπŸ“Έ Taking final screenshot...');
 
 
 
 
 
 
 
774
  await page.screenshot({
775
  path: './betking-final.png',
776
  fullPage: true
 
106
  }
107
 
108
  const browser = await puppeteer.launch({
109
+ headless: false,
110
  args: [
111
  '--no-sandbox',
112
  '--disable-setuid-sandbox',
 
231
 
232
  // First, navigate to the domain to establish context
233
  try {
234
+ // Try login page directly for cookie context
235
+ await page.goto('https://m.betking.com/en-ng/my-accounts/login', {
236
  waitUntil: 'domcontentloaded',
237
  timeout: 15000
238
  });
239
+ console.log('βœ“ Login page loaded for cookie context');
240
 
241
  // Wait a bit for any Cloudflare JS to run
242
  await wait(3000);
243
  } catch (baseError) {
244
+ console.log('⚠️ Initial login page load issue, trying base domain...');
245
+ try {
246
+ await page.goto('https://m.betking.com/', {
247
+ waitUntil: 'domcontentloaded',
248
+ timeout: 15000
249
+ });
250
+ console.log('βœ“ Base domain loaded');
251
+ await wait(3000);
252
+ } catch (fallbackError) {
253
+ console.log('⚠️ Base domain also failed, setting domain manually...');
254
+ await page.evaluateOnNewDocument(() => {
255
+ document.domain = 'betking.com';
256
+ });
257
+ }
258
  }
259
 
260
  // Now set all cookies
 
486
  console.log('\n🌐 Navigating to the page...');
487
  await randomWait(500, 1500);
488
 
489
+ // Navigate directly to login page
490
+ const targetUrl = 'https://m.betking.com/en-ng/my-accounts/login?urlAfterLogin=/en-ng';
491
+ console.log(`Target: ${targetUrl}`);
492
+
493
  let response;
494
  try {
495
+ response = await page.goto(targetUrl, {
496
  waitUntil: ['domcontentloaded', 'networkidle2'],
497
  timeout: 45000
498
  });
 
711
  }
712
  }
713
 
714
+ console.log('\n⏳ Waiting 10 seconds...');
715
+ await wait(10000);
716
 
717
  // Take initial screenshot
718
  console.log('\nπŸ“Έ Taking initial screenshot...');
 
721
  fullPage: true
722
  });
723
 
724
+ console.log('\nπŸ” Checking if we bypassed 403 - looking for login input...');
 
 
 
 
 
 
725
 
726
+ // Check for username input field
727
+ let loginInputFound = false;
728
+ let bypass403Success = false;
729
+
730
+ try {
731
+ const usernameInput = await page.$('#username');
732
+ if (usernameInput) {
733
+ loginInputFound = true;
734
+ bypass403Success = true;
735
+ console.log('βœ… SUCCESS! Found username input - 403 bypass worked!');
736
+ console.log('βœ“ We are on the real login page!');
737
+
738
+ // Check if input is visible
739
+ const isVisible = await usernameInput.isIntersectingViewport();
740
+ console.log(`Username input is visible: ${isVisible}`);
741
+
742
+ // Get input attributes for confirmation
743
+ const inputInfo = await page.evaluate(() => {
744
+ const input = document.querySelector('#username');
745
+ if (input) {
746
+ return {
747
+ id: input.id,
748
+ type: input.type,
749
+ name: input.name,
750
+ placeholder: input.placeholder,
751
+ class: input.className
752
+ };
 
753
  }
754
+ return null;
755
+ });
756
+
757
+ if (inputInfo) {
758
+ console.log('πŸ“‹ Input field details:');
759
+ console.log(JSON.stringify(inputInfo, null, 2));
760
  }
761
+
762
+ // Check for other login elements
763
+ const otherElements = await page.evaluate(() => {
764
+ return {
765
+ passwordField: !!document.querySelector('#password') || !!document.querySelector('input[type="password"]'),
766
+ loginButton: !!document.querySelector('button[type="submit"]'),
767
+ totalInputs: document.querySelectorAll('input').length,
768
+ totalButtons: document.querySelectorAll('button').length,
769
+ pageTitle: document.title,
770
+ hasLoginForm: !!document.querySelector('form')
771
+ };
772
+ });
773
+
774
+ console.log('πŸ“Š Page structure analysis:');
775
+ console.log(` - Password field found: ${otherElements.passwordField}`);
776
+ console.log(` - Login button found: ${otherElements.loginButton}`);
777
+ console.log(` - Total inputs: ${otherElements.totalInputs}`);
778
+ console.log(` - Total buttons: ${otherElements.totalButtons}`);
779
+ console.log(` - Page title: ${otherElements.pageTitle}`);
780
+ console.log(` - Has form: ${otherElements.hasLoginForm}`);
781
+
782
+ } else {
783
+ console.log('❌ Username input NOT found - still blocked or wrong page');
784
  }
785
+ } catch (error) {
786
+ console.log(`⚠️ Error checking for input: ${error.message}`);
787
  }
788
 
789
+ // Also check if we're still on Cloudflare page
790
+ const stillOnCloudflare = await page.evaluate(() => {
791
+ const body = document.body.innerText;
792
+ const title = document.title;
793
+ return (
794
+ body.includes('Just a moment') ||
795
+ body.includes('Checking your browser') ||
796
+ body.includes('Verify you are human') ||
797
+ title.includes('Just a moment') ||
798
+ body.includes('Cloudflare')
799
+ );
800
+ });
801
+
802
+ if (stillOnCloudflare) {
803
+ console.log('⚠️ Still on Cloudflare challenge page');
804
+ } else if (!loginInputFound) {
805
+ console.log('⚠️ Not on Cloudflare, but also not on login page - checking what page we\'re on...');
806
+
807
+ const pageInfo = await page.evaluate(() => {
808
+ return {
809
+ url: window.location.href,
810
+ title: document.title,
811
+ bodyText: document.body.innerText.substring(0, 500),
812
+ h1: document.querySelector('h1')?.innerText,
813
+ errorMessage: document.querySelector('.error-message')?.innerText ||
814
+ document.querySelector('[class*="error"]')?.innerText
815
+ };
816
  });
817
+
818
+ console.log('πŸ“„ Current page info:');
819
+ console.log(` - URL: ${pageInfo.url}`);
820
+ console.log(` - Title: ${pageInfo.title}`);
821
+ console.log(` - H1: ${pageInfo.h1}`);
822
+ if (pageInfo.errorMessage) {
823
+ console.log(` - Error message: ${pageInfo.errorMessage}`);
824
+ }
825
  }
826
 
827
  console.log('\nπŸ“Έ Taking final screenshot...');
828
+
829
+ if (bypass403Success) {
830
+ console.log('πŸŽ‰ STATUS: 403 BYPASS SUCCESSFUL - Login page reached!');
831
+ } else {
832
+ console.log('❌ STATUS: 403 bypass failed or still on challenge page');
833
+ }
834
+
835
  await page.screenshot({
836
  path: './betking-final.png',
837
  fullPage: true