Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # Filename: set_yandex_default_search_engine.py
- # Author: Jeoi Reqi
- """
- Set Default Search Engine in Google Chrome
- This Python script allows users to easily set their default search engine in Google Chrome to the Yandex Search Engine.
- Requirements:
- - Python 3
- Usage:
- 1: Ensure Python 3 is installed on your system.
- 2: Copy and paste the script into a Python file.
- 3: Customize the search engine settings within the script if desired.
- 4: Run the script.
- The script will update your Chrome preferences, setting the Yandex Search Engine as the default.
- Note: Make sure to run the script with the appropriate permissions, and modify the Chrome preferences file path if your Chrome installation directory differs.
- """
- import os
- import json
- # Path to the Chrome preferences file
- PREFS_FILE = os.path.join(os.getenv('LOCALAPPDATA'), 'Google', 'Chrome', 'User Data', 'Default', 'Preferences')
- # Search engine settings to add to the Chrome preferences
- YANDEX_SEARCH_ENGINE = {
- "default_search_provider": {
- "enabled": True,
- "encodings": {"query": "UTF-8", "search_url": "UTF-8"},
- "favicon_url": "https://yandex.com/favicon.ico",
- "id": "3",
- "image_url": "https://yandex.com/images/logo-share.png",
- "image_url_post_params": "",
- "instant_url": "",
- "keyword": "yandex.com",
- "name": "Yandex",
- "search_url": "https://yandex.com/search/?text={searchTerms}",
- "suggest_url": ""
- }
- }
- # Check if the Chrome preferences file exists
- if not os.path.isfile(PREFS_FILE):
- print("Error: Chrome preferences file not found")
- exit(1)
- # Read current preferences from the file
- with open(PREFS_FILE, 'r', encoding='utf-8') as file:
- preferences = json.load(file)
- # Update preferences with Yandex as a search engine
- preferences.update(YANDEX_SEARCH_ENGINE)
- # Write the updated preferences back to the file
- with open(PREFS_FILE, 'w', encoding='utf-8') as file:
- json.dump(preferences, file, indent=2)
- print("Success: Yandex has been added as a search engine in Google Chrome with ID 3")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement