cookie monster

Yeah, I wouldn’t recommend doing this. It’s old. Probably doesn’t work anymore anyway.

I don’t like cookies so much. The persistent browser types, with expiry dates of 2031 that cause a trail of my identity to be left across Google and other sites. And I don’t like how poorly Safari manages them. Even a checkbox option would be better, to keep the ones I need or don’t mind and to delete all the others instead of manually having to go through them all.

SafariPlus used to do this perfectly, from within the browser, unobtrusively. But since 10.5 and Safari 3, it hasn’t worked. So I changed to Cocoa Cookie, a separate small utility. I had to go to my Applications folder to find it, but was still quick and… then it stopped working, it would open without the window showing, caused much weirdness with Safari’s cookies since the latest version and…

uuuhhh… annoyance.

I found a Perl script a couple of days ago. I suppose it could also be done in AppleScript, and should really learn how to write in that, but it’s rather perfect. Well it runs from Terminal also, and requires some editing, but…
#!/usr/bin/perl

use strict;
use warnings;
use File::Slurp;

### Edit this to your liking (put a pipe character between two words)
my $keepCookiesWith = "gaydargirls|culturedcode|supernaut|dreamhost";

### Put your OS X short username here (there should be a directory with the same name under /Users)
my $userName = "francesdath";

### ### ### Don't edit beneath this line unless you know some Perl
my $path = "/Users/francesdath/Library/Cookies/Cookies.plist";
my @date = localtime();
my $date = sprintf("%04d%02d%02d", $date[5] + 1900, $date[4] + 1, $date[3]);
my $cookies = read_file($path);
rename ($path, $path . "." . $date);

open(WH, ">$path");
print WH <<EOF;
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/
PropertyList-1.0.dtd">
<plist version="1.0">
<array>
EOF
while ($cookies =~ m#(\s*<dict>.+?</dict>)#gs)
{
my $cookie = $1;
if ($cookie =~ /$keepCookiesWith/)
{
print WH $cookie;
}
}
print WH <<EOF;

</array>
</plist>
EOF
close (WH);

So, copy it into your favourite text editor, save as something memorable like ‘SafariCookiecleaner.pl’ and put it somewhere out of the way but not forgettable. You can add new cookies to be saved based on any attribute that appears in the Safari cookie window. I tend to use the domain names, like ‘macosxhints’, though I have one Google cookie I like to keep, with the name ‘PREF’, so I added that also (unfortunately YouTube has one with the same name…). Set the ‘username’ to your Home Folder (probably what appears in the SideBar in the Finder), and then set ‘my $path = “”;’ to ‘/Users/yourhomefolder/Library/Cookies/Cookies.plist’ which is the path to Safari’s cookies file.

Then open Terminal, and change to the directory where you’ve put it, change the permissions to 755 and then run it (quit Safari first).

Well like this:
cd /drag/the/folder/containing/the/script/into/Terminal
chmod 755 SafariCookieCleaner.pl
./SafariCookieCleaner.pl

Open Safari, look in cookies in Preferences and the ones you like should still be there. It makes a backup of the cookies file, so at worst nothing is irreparable. And it makes you look all UNIX by opening Terminal.

i can’t stop hacking my system

It is a real drag getting around the China Firewall. Well, not really if I bothered to take my internet privacy as seriously as I do mucking around with my PowerBook. The firewall has been getting more stroppy lately, or maybe its’ my enhanced internet suctioning. So I spent the evening installing some back-end software that I hoped would make the appearance of a firewall something of a non-sequitur. Once it was all mostly running, I started thinking about what other condiments I have added to my system, and it turned into quite a list.

The three applications I use everyday and in heavy conjunction are Safari, Mail, and iCal, and all of them are fairly tweaked. Safari uses Saft primarily for url shortcuts, and some other gui hackery, followed by PithHelmet for hardarse piss-off ad-blocking and page-view modification. Yes I read your code too, and it looks pretty colours with SafariSource. The final and very heavily-used add-on is LiveDictionary, for all my Chinese-English translating. I also like rewriting plists, so LiveDictionary now also works in TextEdit, Mail, and ecto blogging utopia.

Mail I left alone until I destroyed it in January. Then I added Mail-Tags and Mail Act-On. I’ve given up on organising stuff via specific folders, and just dump everything into folder by month then use lots of smart folders and Mail-Tags to find stuff, and it looks like a candy-store now, mmm so pretty… Mail talks to iCal (keeping the correct time in every city with iCalTimeZoneFixer) with Event Maker, a very simple gui for some AppleScripts that shunts stuff across without having to screw around filling out every field. And they all talk with my Sony-Ericsson K750c (full of Chinese-input goodness) thanks to BluePhone Elite.

Staying with my phone, shortly after I got it, I discovered I could foo with some stuff and my very old PowerBook would run Front Row and my phone would become the remote control. I’d use it more if I didn’t have Sex & Fury stuck in my DVD drive…

Beyond the really quite beautiful gui of OSX (besides ‘brushed metal’ that kinda sounds like Zoolander’s ‘blue steel’ and looks very like a fat robot has dumped on the screen) is the joy of command-line. Yay for Terminal, yay for uptime – the first command I learnt and still use. My hard drive I fear is getting old, and there are no good SMART tools around except for smartmontools, that MacOSXHints has been on about over the last few days.

The other recent addition to /usr/local/bin/ is TOR, and that takes me back to the firewall. I’ve tried a lot of circumvention methods recently, and in the past when I would try out any and every network exploitation/anonymisation/encryption thing I’d come across. Most of them are either crap or don’t work. The category of ‘crap’ includes everything that in any way is noticeable in a deleterious form on normal network usage. This includes the most common two circumventors, anonymouse and stupid censorship. I’m still not sure about TOR yet, it works but is slow. Like dial-up.

Besides all that, I also have WeatherDock tell me it is sunny in Guangzhou (it is rainy and nighttime), MenuMeters telling me I’m pulling down 50k/s of traffic (I’m not), ecto is writing this (I’m in bed asleep), NetNewsWire takes care of 223 feeds, added privacy from Little Snitch, I’ve disabled Exposé and Dashboard (both are unnecessary if you’re handy with the keyboard and using existing OSX software and some plugins).