How to block google image on terminal?

Discussion in 'Mac Basics and Help' started by miki95, Aug 9, 2015.

  1. miki95 macrumors newbie

    Aug 9, 2015
    Hey everyone,

    How can i do that without blocking google search engine as whole?
  2. AidenShaw macrumors P6


    Feb 8, 2003
    The Peninsula
    Why wouldn't you want to block completely?
  3. miki95 thread starter macrumors newbie

    Aug 9, 2015
    hey, im porn addict. I don't want to block google as a whole, just entering google image section
  4. 0d085d macrumors regular

    Apr 23, 2015
    This is difficult - partially because Google images isn't even a separate subdomain anymore, but mostly because it's almost impossible to put in any sort of block that you can't overrule the moment you feel like it.

    Nevertheless, here's my attempt at a solution.

    1. Create a separate administrator account and log in to it. Make sure your day to day user account is not an administrator.

    2. Create a new text document in TextEdit and press cmd+shift+T to convert to plain text. Paste the following in and then save it to the Public folder inside the admin user's home folder as proxy.pac.
    var normal = "DIRECT", blackhole = "PROXY";
    function testpat(regexpr, url) {
        var pat = new RegExp(regexpr)
        return pat.test(url)
    function FindProxyForURL(url, host) {
        tests = [ "google.*=images",
        for( var i = 0; i < tests.length; i++ ) {
            if( testpat(tests[i], url) ) {
                return blackhole;
        return normal;
    3. Open Terminal and type the following commands:
    cd Public
    chmod og-w proxy.pac
    chmod og+r proxy.pac
    4. Now go into System Preferences -> Network and select Wi-Fi or whatever your normal network interface is. Click the padlock in the bottom left then give it your admin username and password. Click the Advanced... button towards the bottom right and then the Proxies tab at the top.

    5. Select Automatic Proxy Configuration and put the following in the URL box, substituting admin for the username of the admin user. Note there are three forward slashes at the beginning.
    6. Click Okay then Apply.

    That should have blocked everything remotely resembling Google Images in most browsers, but Safari (*sigh*) has some bugs (?) that (eurgh) prevent the proxy from working. Luckily, we can lock Safari out as well:

    7. Open Terminal again and type the following commands. Note that the last command will ask for your password, and that nothing will appear as you type it in. This is normal. Just keep typing and hit enter at the end.
    cd /Applications
    sudo chmod ugo-x

    Your regular user should now be totally unable to access Google Images. Let me know if you find a hole anywhere or have trouble with any of the instructions. If you need to lock yourself out of the administrator account as well, that can be arranged, but life will start getting difficult from there.

Share This Page