-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: browser improvements #259
Conversation
feat: add check for selector visibility, revert domcontentloaded to networkidle state
Caution Review failedThe pull request is closed. WalkthroughThe pull request introduces modifications to two key files: Changes
Possibly related PRs
Poem
Tip CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Outside diff range and nitpick comments (2)
maxun-core/src/interpret.ts (2)
195-196
: Consider removing commented-out code for clarity.The code at lines 190-211, including the
actionable
function, is commented out. If this code is no longer needed, consider removing it to improve code readability and maintainability.
218-227
: Specify a timeout forpage.waitForSelector
to prevent indefinite waits.Consider specifying a timeout for
page.waitForSelector
to prevent the function from waiting indefinitely if the selector does not appear.Apply this diff to add a timeout:
- await page.waitForSelector(selector, { state: 'attached' }); + await page.waitForSelector(selector, { state: 'attached', timeout: 10000 });
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
maxun-core/src/interpret.ts
(4 hunks)server/src/browser-management/classes/RemoteBrowser.ts
(6 hunks)
🔇 Additional comments (3)
maxun-core/src/interpret.ts (1)
782-782
: Verify necessity of increasing default navigation timeout to 100000ms.
Setting page.setDefaultNavigationTimeout(100000);
increases the navigation timeout to 100 seconds. Ensure that this increase is necessary and does not mask underlying issues with slow page loads.
server/src/browser-management/classes/RemoteBrowser.ts (2)
133-137
: Good job adding error handling in injectScript
function.
The error handling and logging in the injectScript
function within the load
event handler will aid in diagnosing script injection issues.
218-241
: Verify that the injected script to hide navigator.webdriver
works correctly.
Review the injected script to ensure it properly hides the navigator.webdriver
property and doesn't introduce errors.
args: [ | ||
"--disable-blink-features=AutomationControlled", | ||
"--disable-web-security", | ||
"--disable-features=IsolateOrigins,site-per-process", | ||
"--disable-site-isolation-trials", | ||
"--disable-extensions" | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review necessity of disabling security features in Chromium launch arguments.
Disabling features like --disable-web-security
may expose the browser to security risks. Ensure that disabling these features is necessary and consider alternative approaches.
private getUserAgent() { | ||
const userAgents = [ | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.140 Safari/537.36', | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:117.0) Gecko/20100101 Firefox/117.0', | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.1938.81 Safari/537.36 Edg/116.0.1938.81', | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.96 Safari/537.36 OPR/101.0.4843.25', | ||
'Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.62 Safari/537.36', | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:118.0) Gecko/20100101 Firefox/118.0', | ||
]; | ||
|
||
return userAgents[Math.floor(Math.random() * userAgents.length)]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify the accuracy of user agent strings in getUserAgent
.
The user agent string 'Mozilla/5.0 (Windows NT 11.0; Win64; x64)...'
may not be accurate since Windows typically reports as 'Windows NT 10.0'. Ensure user agent strings are accurate to avoid detection.
Apply this diff to correct the user agent string:
- 'Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.62 Safari/537.36',
+ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.62 Safari/537.36',
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
private getUserAgent() { | |
const userAgents = [ | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.140 Safari/537.36', | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:117.0) Gecko/20100101 Firefox/117.0', | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.1938.81 Safari/537.36 Edg/116.0.1938.81', | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.96 Safari/537.36 OPR/101.0.4843.25', | |
'Mozilla/5.0 (Windows NT 11.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.62 Safari/537.36', | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:118.0) Gecko/20100101 Firefox/118.0', | |
]; | |
return userAgents[Math.floor(Math.random() * userAgents.length)]; | |
} | |
private getUserAgent() { | |
const userAgents = [ | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.140 Safari/537.36', | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:117.0) Gecko/20100101 Firefox/117.0', | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.1938.81 Safari/537.36 Edg/116.0.1938.81', | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.5845.96 Safari/537.36 OPR/101.0.4843.25', | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.5938.62 Safari/537.36', | |
'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:118.0) Gecko/20100101 Firefox/118.0', | |
]; | |
return userAgents[Math.floor(Math.random() * userAgents.length)]; | |
} |
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores