def install_chrome(self, installer_path): """Launch the Chrome installer""" system = platform.system() if not installer_path or not installer_path.exists(): print("Installer file not found") return False try: if system == "Windows": print("Launching Chrome installer...") subprocess.run([str(installer_path)], shell=True) print("Installer launched. Please follow the installation wizard.") elif system == "Darwin": print("Opening Chrome DMG...") subprocess.run(['open', str(installer_path)]) print("DMG opened. Please drag Chrome to Applications folder.") elif system == "Linux": print("Installing Chrome DEB package...") subprocess.run(['sudo', 'dpkg', '-i', str(installer_path)], check=True) print("Installation complete") return True except Exception as e: print(f"Installation failed: {e}") return False
def check_and_update(self): """Main function to check for updates and download if needed""" print("=" * 50) print("Chrome Updater") print("=" * 50) # Get current version current_version = self.get_current_chrome_version() if current_version: print(f"Current Chrome version: {current_version}") else: print("Could not detect current Chrome version") # Get latest version latest_version = self.get_latest_chrome_version() if latest_version: print(f"Latest Chrome version: {latest_version}") else: print("Could not fetch latest version") # Compare versions if current_version and latest_version: if current_version == latest_version: print("\n✓ Chrome is already up to date!") return # Download and install print(f"\n🔄 New version available. Downloading Chrome {latest_version}...") installer = self.download_chrome_installer(latest_version) if installer: print(f"\n✅ Download successful!") response = input("\nDo you want to install now? (y/n): ") if response.lower() == 'y': self.install_chrome(installer) else: print(f"Installer saved at: {installer}") else: print("❌ Download failed. Please check your internet connection.") def main(): updater = ChromeUpdater() updater.check_and_update() new version of chrome download
import requests import platform import os import json from pathlib import Path import subprocess import sys class ChromeUpdater: def init (self): self.base_url = "https://www.googleapis.com/download/storage/v1/b/chrome-omaha/o" self.download_dir = Path.home() / "Downloads" / "chrome_installers" Downloading Chrome {latest_version}
// Chrome Version Checker (JavaScript/HTML) async function checkChromeVersion() { const response = await fetch('https://versionhistory.googleapis.com/v1/chrome/platforms/win64/channels/stable/versions'); const data = await response.json(); const latestVersion = data.versions[0].version; // Get current Chrome version from user agent const currentVersion = navigator.userAgent.match(/Chrome\/(\d+\.\d+\.\d+\.\d+)/)[1]; const data = await response.json()
console.log(`Current: ${currentVersion}`); console.log(`Latest: ${latestVersion}`);
def download_chrome_installer(self, version=None): """Download the latest Chrome installer""" # Create download directory self.download_dir.mkdir(parents=True, exist_ok=True) system = platform.system() arch = platform.machine() # Determine download URL based on OS if system == "Windows": if arch == "AMD64": download_url = "https://dl.google.com/chrome/install/latest/chrome_installer.exe" else: download_url = "https://dl.google.com/chrome/install/latest/chrome_installer_win32.exe" filename = f"chrome_installer_{version or 'latest'}.exe" elif system == "Darwin": download_url = "https://dl.google.com/chrome/mac/stable/GGRO/googlechrome.dmg" filename = f"googlechrome_{version or 'latest'}.dmg" elif system == "Linux": if arch == "x86_64": download_url = "https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb" else: download_url = "https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb" filename = f"google-chrome-stable_{version or 'latest'}.deb" else: raise Exception(f"Unsupported OS: {system}") filepath = self.download_dir / filename print(f"Downloading Chrome installer from: {download_url}") print(f"Saving to: {filepath}") try: response = requests.get(download_url, stream=True) response.raise_for_status() total_size = int(response.headers.get('content-length', 0)) downloaded = 0 with open(filepath, 'wb') as f: for chunk in response.iter_content(chunk_size=8192): f.write(chunk) downloaded += len(chunk) # Progress indicator if total_size > 0: progress = (downloaded / total_size) * 100 print(f"\rProgress: {progress:.1f}%", end='') print(f"\n✓ Download complete: {filepath}") return filepath except Exception as e: print(f"\n✗ Download failed: {e}") return None
def get_current_chrome_version(self): """Get installed Chrome version""" system = platform.system() try: if system == "Windows": import winreg key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Google\Chrome\BLBeacon") version = winreg.QueryValueEx(key, "version")[0] return version elif system == "Darwin": # macOS result = subprocess.run( ['/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', '--version'], capture_output=True, text=True ) return result.stdout.split()[-1] elif system == "Linux": result = subprocess.run(['google-chrome', '--version'], capture_output=True, text=True) return result.stdout.split()[-1] except Exception as e: print(f"Could not get current version: {e}") return None