Created
June 2, 2009 06:36
-
-
Save pc/122104 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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