{"id":2107,"date":"2025-07-12T06:27:09","date_gmt":"2025-07-12T06:27:09","guid":{"rendered":"https:\/\/expatcircle.com\/cms\/?p=2107"},"modified":"2025-07-12T06:31:28","modified_gmt":"2025-07-12T06:31:28","slug":"privacy-advanced-ublock-origin-wont-work-with-chrome-anymore-ad-and-tracker-blocking-using-a-hosts-file","status":"publish","type":"post","link":"https:\/\/expatcircle.com\/cms\/privacy-advanced-ublock-origin-wont-work-with-chrome-anymore-ad-and-tracker-blocking-using-a-hosts-file\/","title":{"rendered":"Privacy [Advanced]: uBlock Origin won&#8217;t work with Chrome anymore. Ad and tracker blocking using a hosts file"},"content":{"rendered":"<p dir=\"auto\"><strong>For Tech-Savvy Users: Enhance Your Online Privacy<\/strong><\/p>\n<p dir=\"auto\"><a href=\"https:\/\/ublockorigin.com\/\" target=\"_blank\" rel=\"noopener\"><strong>uBlock Origin<\/strong><\/a>: A powerful, free, and open-source ad blocker. Note: It is no longer compatible with the latest versions of Google Chrome.<\/p>\n<p dir=\"auto\">For optimal security and privacy, use multiple browsers tailored to specific tasks:<\/p>\n<ul dir=\"auto\">\n<li><strong>Banking Browser<\/strong>: Choose a major browser (e.g., Chrome, Firefox, Edge) without plug-ins to ensure maximum compatibility and security.<\/li>\n<li><strong>Web Surfing Browser<\/strong>: Opt for a privacy-hardened browser (e.g., Firefox with privacy extensions or Tor) equipped with robust plug-ins for enhanced protection.<\/li>\n<\/ul>\n<p dir=\"auto\"><strong>Additional Privacy Solution: Host File Blocking<\/strong><\/p>\n<p dir=\"auto\">To further block ads and trackers, consider using a host file-based solution. This method provides an extra layer of protection but is just one part of a multi-layered privacy strategy. Be aware that host file blocking may interfere with certain websites, such as flight aggregators, causing them to function improperly.<\/p>\n<p dir=\"auto\"><strong>Custom Python Script for Host File Management<\/strong><\/p>\n<p dir=\"auto\">I\u2019ve developed a Python script that simplifies host file management by combining multiple host files into a single, optimized file. The script also includes convenient features to enable or disable blocking, allowing you to bypass issues with specific websites when needed. It supports three commands:<\/p>\n<p>\u00a01. Build the custom blocklist version: \u00a0sudo python3 hosts_manager.py &#8211;build<\/p>\n<p>2. Activate the blocklist :\u00a0sudo python3 hosts_manager.py &#8211;on<\/p>\n<p>3. Revert to generic clean version: \u00a0sudo python3 hosts_manager.py &#8211;off<\/p>\n<blockquote>\n<pre><code class=\"language-python\">\r\n#!\/usr\/bin\/env python3\r\nimport os\r\nimport shutil\r\nimport urllib.request\r\n\r\n# Configuration\r\nSOURCES = [\r\n    \"https:\/\/someonewhocares.org\/hosts\/hosts\",\r\n    \"https:\/\/raw.githubusercontent.com\/StevenBlack\/hosts\/master\/hosts\",\r\n    \"https:\/\/adaway.org\/hosts.txt\",\r\n]\r\nLOCALHOST_LINES = [\r\n    \"127.0.0.1 localhost\",\r\n    \"::1 localhost\"\r\n]\r\nCUSTOM_HOSTS_PATH = \"\/etc\/hosts\"\r\nGENERIC_HOSTS_PATH = \"\/etc\/hosts.generic\"\r\nBLOCKED_HOSTS_PATH = \"\/etc\/hosts.blocked\"\r\n\r\ndef download_sources():\r\n    lines = set()\r\n    for url in SOURCES:\r\n        print(f\"Downloading: {url}\")\r\n        try:\r\n            with urllib.request.urlopen(url) as response:\r\n                for raw_line in response.read().decode(\"utf-8\", errors=\"ignore\").splitlines():\r\n                    line = raw_line.strip()\r\n                    if not line or line.startswith(\"#\"):\r\n                        continue\r\n                    parts = line.split()\r\n                    if len(parts) &gt;= 2 and (parts[0].startswith(\"127.\") or parts[0] == \"0.0.0.0\"):\r\n                        lines.add(f\"{parts[0]} {parts[1]}\")\r\n        except Exception as e:\r\n            print(f\"Failed to download {url}: {e}\")\r\n    return sorted(lines)\r\n\r\ndef write_hosts_file(path, entries):\r\n    with open(path, \"w\") as f:\r\n        for line in LOCALHOST_LINES:\r\n            f.write(line + \"\\n\")\r\n        f.write(\"\\n\")\r\n        for entry in entries:\r\n            f.write(entry + \"\\n\")\r\n    print(f\"Written: {path}\")\r\n\r\ndef backup_original():\r\n    if not os.path.exists(GENERIC_HOSTS_PATH):\r\n        print(\"Backing up current hosts file as generic version\u2026\")\r\n        shutil.copy(CUSTOM_HOSTS_PATH, GENERIC_HOSTS_PATH)\r\n\r\ndef activate_custom_hosts():\r\n    if os.path.exists(BLOCKED_HOSTS_PATH):\r\n        shutil.copy(BLOCKED_HOSTS_PATH, CUSTOM_HOSTS_PATH)\r\n        print(\"Custom blocked hosts file activated.\")\r\n    else:\r\n        print(\"Blocked hosts file not found. Please run with `--build` first.\")\r\n\r\ndef deactivate_custom_hosts():\r\n    if os.path.exists(GENERIC_HOSTS_PATH):\r\n        shutil.copy(GENERIC_HOSTS_PATH, CUSTOM_HOSTS_PATH)\r\n        print(\"Reverted to generic hosts file.\")\r\n    else:\r\n        print(\"No generic hosts backup found.\")\r\n\r\ndef main():\r\n    import argparse\r\n    parser = argparse.ArgumentParser()\r\n    parser.add_argument(\"--build\", action=\"store_true\", help=\"Download and build blocked hosts file\")\r\n    parser.add_argument(\"--on\", action=\"store_true\", help=\"Activate blocked hosts\")\r\n    parser.add_argument(\"--off\", action=\"store_true\", help=\"Revert to generic hosts\")\r\n    args = parser.parse_args()\r\n\r\n    if args.build:\r\n        backup_original()\r\n        entries = download_sources()\r\n        write_hosts_file(BLOCKED_HOSTS_PATH, entries)\r\n        print(\"Blocked hosts file built.\")\r\n    elif args.on:\r\n        activate_custom_hosts()\r\n    elif args.off:\r\n        deactivate_custom_hosts()\r\n    else:\r\n        parser.print_help()\r\n\r\nif __name__ == \"__main__\":\r\n    main()\r\n<\/code><\/pre>\n<\/blockquote>\n<p>My host file was on &#8220;on&#8221; and I did not even realize that ublock does not work anymore.<\/p>\n<p>Need privacy consulting? <a href=\"https:\/\/expatcircle.com\/cms\/contact-us\/\">Book an appointment.\u00a0<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>For Tech-Savvy Users: Enhance Your Online Privacy uBlock Origin: A powerful, free, and open-source ad blocker. Note: It is no longer compatible with the latest versions of Google Chrome. For optimal security and privacy, use multiple browsers tailored to specific tasks: Banking Browser: Choose a major browser (e.g., Chrome, Firefox, Edge) without plug-ins to ensure [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_links_to":"","_links_to_target":""},"categories":[39,25],"tags":[],"class_list":["post-2107","post","type-post","status-publish","format-standard","hentry","category-fly-under-the-radar","category-privacy"],"_links":{"self":[{"href":"https:\/\/expatcircle.com\/cms\/wp-json\/wp\/v2\/posts\/2107","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expatcircle.com\/cms\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expatcircle.com\/cms\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expatcircle.com\/cms\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expatcircle.com\/cms\/wp-json\/wp\/v2\/comments?post=2107"}],"version-history":[{"count":5,"href":"https:\/\/expatcircle.com\/cms\/wp-json\/wp\/v2\/posts\/2107\/revisions"}],"predecessor-version":[{"id":2111,"href":"https:\/\/expatcircle.com\/cms\/wp-json\/wp\/v2\/posts\/2107\/revisions\/2111"}],"wp:attachment":[{"href":"https:\/\/expatcircle.com\/cms\/wp-json\/wp\/v2\/media?parent=2107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expatcircle.com\/cms\/wp-json\/wp\/v2\/categories?post=2107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expatcircle.com\/cms\/wp-json\/wp\/v2\/tags?post=2107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}