mirror of
https://github.com/yeongpin/cursor-free-vip.git
synced 2025-08-02 20:47:35 +08:00

This commit fixes that error when you had an custom chrome installation. For example: D:\Chromium or something. Now it uses windows PATH to start chrome and if there's no PATH installation script would check default location. Here's demo for current bug: https://youtu.be/O8lPblnBIGQ
78 lines
2.6 KiB
Python
78 lines
2.6 KiB
Python
import os
|
|
import sys
|
|
import platform
|
|
import random
|
|
|
|
def get_user_documents_path():
|
|
"""Get user documents path"""
|
|
if platform.system() == "Windows":
|
|
return os.path.expanduser("~\\Documents")
|
|
else:
|
|
return os.path.expanduser("~/Documents")
|
|
|
|
def get_default_chrome_path():
|
|
"""Get default Chrome path"""
|
|
if sys.platform == "win32":
|
|
# Trying to find chrome in PATH
|
|
try:
|
|
import shutil
|
|
chrome_in_path = shutil.which("chrome")
|
|
if chrome_in_path:
|
|
return chrome_in_path
|
|
except:
|
|
pass
|
|
# Going to default path
|
|
return r"C:\Program Files\Google\Chrome\Application\chrome.exe"
|
|
elif sys.platform == "darwin":
|
|
return "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
|
|
else:
|
|
return "/usr/bin/google-chrome"
|
|
|
|
def get_linux_cursor_path():
|
|
"""Get Linux Cursor path"""
|
|
possible_paths = [
|
|
"/opt/Cursor/resources/app",
|
|
"/usr/share/cursor/resources/app",
|
|
"/opt/cursor-bin/resources/app",
|
|
"/usr/lib/cursor/resources/app",
|
|
os.path.expanduser("~/.local/share/cursor/resources/app")
|
|
]
|
|
|
|
# return the first path that exists
|
|
return next((path for path in possible_paths if os.path.exists(path)), possible_paths[0])
|
|
|
|
def get_random_wait_time(config, timing_key):
|
|
"""Get random wait time based on configuration timing settings
|
|
|
|
Args:
|
|
config (dict): Configuration dictionary containing timing settings
|
|
timing_key (str): Key to look up in the timing settings
|
|
|
|
Returns:
|
|
float: Random wait time in seconds
|
|
"""
|
|
try:
|
|
# Get timing value from config
|
|
timing = config.get('Timing', {}).get(timing_key)
|
|
if not timing:
|
|
# Default to 0.5-1.5 seconds if timing not found
|
|
return random.uniform(0.5, 1.5)
|
|
|
|
# Check if timing is a range (e.g., "0.5-1.5" or "0.5,1.5")
|
|
if isinstance(timing, str):
|
|
if '-' in timing:
|
|
min_time, max_time = map(float, timing.split('-'))
|
|
elif ',' in timing:
|
|
min_time, max_time = map(float, timing.split(','))
|
|
else:
|
|
# Single value, use it as both min and max
|
|
min_time = max_time = float(timing)
|
|
else:
|
|
# If timing is a number, use it as both min and max
|
|
min_time = max_time = float(timing)
|
|
|
|
return random.uniform(min_time, max_time)
|
|
|
|
except (ValueError, TypeError, AttributeError):
|
|
# Return default value if any error occurs
|
|
return random.uniform(0.5, 1.5) |