#!/usr/bin/perl # # Hack firefox to believe that no web page contains an autocomplete disable # attribute (that will teach stuck up web admins to think their passwords # are too good to be saved in firefox :-). use File::Compare; use File::Copy; # Step 1 - find the nsLoginManager.js file location from the # xulrunner package file list. # my $fh; my $infile; open($fh, '-|', '/bin/rpm', '-q', '--list', 'xulrunner'); while (<$fh>) { if (/\/nsLoginManager\.js$/) { chomp; $infile=$_; last; } } close($fh); undef $fh; # # Step 2 - copy file to temp, replacing the definition of the # _isAutocompleteDisabled function with one which always returns false. # my $outfile = "/tmp/nslm$$.js"; my $outf; open($fh, '<', $infile) || die "Cannot read $infile : $!\n"; open($outf, '>', $outfile) || die "Cannot write $outfile : $!\n"; $found=0; while (<$fh>) { if (/^\s*_isAutocompleteDisabled\s*:\s*function.*\{\s*$/) { $found=1; last; } else { print $outf $_; } } if (! $found) { close($outf); unlink($outfile); die "Did not find _isAutocompleteDisabled function definition!\n"; } print $outf $_; $found=0; while (<$fh>) { if (/^\s*return\s+false\s*\;\s*$/) { $found=1; last; } } if (! $found) { close($outf); unlink($outfile); die "Did not find return false statement!\n"; } print $outf $_; $found=0; while (<$fh>) { if (/^\s*\}/) { $found=1; last; } } if (! $found) { close($outf); unlink($outfile); die "Did not find closing squiggly brace!\n"; } print $outf $_; while (<$fh>) { print $outf $_; } close($fh); close($outf); if (compare($infile, $outfile) != 0) { # Looks like the files are different, I really need to fix the # function. Copy the outfile back over the top of the infile. print "Updating $infile\n"; copy($outfile, $infile); } unlink($outfile);