Disable a referring url in Chrome and Chromium

UPDATE:
Use Referer Control: https://chrome.google.com/webstore/detail/referer-control/hnkcfpcejkafcihlgbojoidoihckciin

---

To permanently disable a referring url in Google Chrome and Chromium, use the following setting in your "Preferences" file to stop sending a referer header on HTTP requests.

The setting is called "enable_referrers" and it needs to be set to false (no quotes) in the json-encoded Preferences ( ~/.config/chromium/Default/Preferences ) file. For Google Chrome look in ~/.config/google-chrome/Default/Preferences

{
...
"enable_referrers": false,
...
}
import json
import os
import time

# current prefs
pref_path = '{0}/.config/chromium/Default/Preferences'.format(os.getenv('HOME'))
prefs = open(pref_path, 'r+')
json_prefs = prefs.read()

# backup
old_prefs = open('{0}.{1}'.format(pref_path, time.time()), 'w')
old_prefs.write(json_prefs)
old_prefs.close()

# disable referrers
new_prefs = json.loads(json_prefs)
new_prefs['enable_referrers'] = False
new_json_prefs = json.dumps(new_prefs, sort_keys=True, indent=4)

# save
prefs.write(new_json_prefs)
prefs.close()

print('DONE')
Notes:
# http://src.chromium.org/svn/trunk/src/chrome/common/pref_names.cc
// Whether to enable sending referrers.
const char kEnableReferrers[] = "enable_referrers";

Other files containing references to "enable_referrers": http://src.chromium.org/svn/trunk/src/content/common/view_messages.h http://src.chromium.org/svn/trunk/src/content/common/renderer_preferences.h http://src.chromium.org/svn/trunk/src/chrome/browser/net/chrome_network_delegate.cc

View this page on GitHub.
Posted .

4 comments

  1. anonymous

    for Google Chrome on Windows look in:

    C:\Users\USERNAME\AppData\Local\Google\Chrome\User Data\Default\Preferences

  2. anonymous

    Google Chrome on OSX is located ~/Library/Application Support/Google/Chrome/Default/Preferences

  3. anonymous

    for Chromium on OSX look in ~/Library/Application Support/Chromium/Default/Preferences

Leave a Reply