Skip to content

Instantly share code, notes, and snippets.



Created Mar 7, 2010
What would you like to do?
Kill bad cookies in WebKit. Uses poor and incomplete heuristics to achieve its goal. Includes a LaunchAgent to run the script every night (path in that must be adapted for your account).
#!/usr/bin/env python
2010 by Sven-S. Porst <>
Script with simple heuristics to kill the most obviously crap cookies in WebKit.
Available at
Better quit cookie users before running the script.
Perhaps run it at login and nightly with a LaunchAgent?
from Foundation import *
evilNames = ["__u", "CFID", "CFTOKEN", "CoreID", ".ASPXANONYMOUS", "ACOOKIE", "AdUserID", "AVPUID", "AWSUSER_ID", "awpopup", "Apache", "bitt", "BX", "CP", "Conversion", "DM", "FC", "GUID", "HstC", "HumanClickID", "ID", "IXA", "JEB2", "LE", "NGUserID", "OAID", "OASIS", "OAX", "POPUPCHECK", "RM", "SID", "TC", "TID", "TRUID", "UID", "UUID", "VISITOR", "VISID", "VisID", "VisitorID", "WEBTRENDS_ID", "WSS_GW", "WT_FPC", "_SUPERFLY", "_OA", "__a", "_bit", "__c", "_dw", "__g", "__k", "__q", "__r", "_c", "_m", "ad", "anon", "bblast", "c1", "eid", "exp_", "emos_", "mds", "meta", "etcnt_", "fpc", "globid", "gmv", "goo", "i00", "iCmpro", "jehiah", "mojo", "OA", "omniID", "omniUserID", "otp", "pb", "phpAds", "pid", "piwik", "re_ret", "ref", "s1", "sUnique", "s_", "ss_lastvisit", "stat_", "suid", "TLTUID", "tu", "um", "v1st", "vid", "VWCUK", "WEBTRENDS", "_w", "wlid", "woo", "wpgb_", "wt_", "XCLGF", "zF" ]
evilDomains = ["", "", "", ".ad", ".doubleclick", "ad", ".statcounter", "track", ".hoc-technology", ".Adjug", ".pubmatic", ".webmaster" ]
path = NSString.stringWithString_("~/Library/Cookies/Cookies.plist").stringByExpandingTildeInPath()
array = NSArray.arrayWithContentsOfFile_(path)
resultCookies = NSMutableArray.array()
count = 0
for cookie in array:
kill = False
name = cookie["Name"]
domain = cookie["Domain"]
for evilName in evilNames:
if name.startswith(evilName):
kill = True
count = count + 1
for evilDomain in evilDomains:
if domain.startswith(evilDomain):
kill = True
count = count + 1
if kill is False:
resultCookies.writeToFile_atomically_(path, True)
print "Killed " + str(count) + " of " + str(len(array)) + " cookies."
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment