Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # Filename: set_duckduckgo_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 DuckDuckGo 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 DuckDuckGo 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
- SEARCH_ENGINE = {
- "default_search_provider": {
- "enabled": True,
- "encodings": {"query": "UTF-8", "search_url": "UTF-8"},
- "favicon_url": "https://duckduckgo.com/favicon.ico",
- "id": "1",
- "image_url": "https://duckduckgo.com/assets/logo.icon.svg",
- "image_url_post_params": "",
- "instant_url": "",
- "keyword": "duckduckgo.com",
- "name": "DuckDuckGo",
- "search_url": "https://duckduckgo.com/?q={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 DuckDuckGo as the default search engine
- preferences.update(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: DuckDuckGo has been set as your default search engine in Google Chrome")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement