Skip to content

Instantly share code, notes, and snippets.

@pc
Created June 2, 2009 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pc/122104 to your computer and use it in GitHub Desktop.
Save pc/122104 to your computer and use it in GitHub Desktop.
require 'digest/md5'
offsets = {
'15a7dcbffe207eca34a72cf632428c32' => 0x4ee480,
'72e779fe7733230c2c74e1a7db190390' => 0x4ee456
}
Safari = "/Applications/Safari.app/Contents/MacOS/Safari"
Safari_old = Safari + ".old"
unless File.exists? Safari
$stderr.puts "Couldn't find Safari at #{Safari}"
exit 1
end
hash = Digest::MD5.hexdigest(File.read(Safari))
offset = offsets[hash]
unless offset
$stderr.puts "I don't know how to patch this version of Safari"
exit 1
end
$stderr.puts "Backing up #{Safari} to #{Safari_old}"
`cp #{Safari} #{Safari}.old`
$stderr.puts "Patching #{Safari}"
File.open(Safari, 'r+') do |f|
f.seek(offset)
f.write("bing.com/%@?q=%@\0")
end
$stderr.puts "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment