Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Disable animated GIFs and blinking text in Netscape

by Anonymous Monk
on Sep 20, 2000 at 22:16 UTC ( [id://33368]=sourcecode: print w/replies, xml ) Need Help??
Category: Web stuff
Author/Contact Info Rich Griswold - griswold@acm.org
Description: Perl script that disables/enables blinking text and/or animated GIFs in Netscape. I've tried this on Netscape for Intel Linux, Digial Unix, and AIX, and I've been told it also works on Netscape for M$ Windoze. Animated GIFs will still run through the cycle one time, stopping on the last frame. As you can see, all it actually does is call perl again to replace a couple of strings inside the Netscape binary to cripple the blinking text and animated GIF support.
#!/usr/bin/perl
#
# 21 MAY 1999:  Created
# 29 OCT 1999:  Added ability to disable blinking text
#               Rewrote argument fetch code
#               Used strict package
# 19 SEP 2000:  Cleanup

use strict;

my $execname;      # Name of this script
my $usage;         # Usage information

my $ag;            # Animated GIF action
my $bt;            # Blinking text action

my $arg;           # An argument

$execname   = $0;
$execname   =~ s/^.+\///;
$usage      = "
Usage: $execname [-ae|-ad] [-be|-bd] <--> file(s) ...
  -ae      Enable animated GIFs
  -ad      Disable animated GIFs
  -be      Enable blinking text
  -bd      Disable blinking text
  --       All other arguments are files
  file(s)  Netscape executable(s)

  Richard Griswold, 21 MAY 1999

";

# Fetch arguments
while ( $#ARGV >= 0 ) {
  $arg = shift ( @ARGV );

  if    ( ( $arg eq "-ae" ) or ( $arg eq "-ad" ) ) { $ag = $arg; }
  elsif ( ( $arg eq "-be" ) or ( $arg eq "-bd" ) ) { $bt = $arg; }
  elsif ( $arg eq "--"  ) { last; }    # Rest of args are files
  else  { unshift @ARGV, $arg; last; } # Rest of args are files
}
if ( not $ag and not $bt ) {
  die "You must specify at least one action\n$usage";
}
if ( $#ARGV < 0 ) {
  die "You must specify at least one file\n$usage";
}

# Check access on each file
foreach $arg ( @ARGV ) {
  if ( !( -e $arg) ) {
    die "File \"$arg\" does not exist.\n$usage";
  }
  if ( !( -f $arg) ) {
    die "File \"$arg\" is not a plain file.\n$usage";
  }
  if ( !( -w $arg) ) {
    die "You do not have write access to file \"$arg\".\n$usage";
  }
}

# Perform action
$arg = join ' ', @ARGV;
if ( $ag eq "-ae" ) {
  `perl -pi -e 's/ANIMEXTZ1.0/ANIMEXTS1.0/' $arg`;
  `perl -pi -e 's/NOTSCAPE2.0/NETSCAPE2.0/' $arg`;
  print "Animated GIFs are enabled in file(s) \"$arg\"\n";
} elsif ( $ag eq "-ad" ) {
  `perl -pi -e 's/ANIMEXTS1.0/ANIMEXTZ1.0/' $arg`;
  `perl -pi -e 's/NETSCAPE2.0/NOTSCAPE2.0/' $arg`;
  print "Animated GIFs are disabled in file(s) \"$arg\"\n";
}
if ( $bt eq "-be" ) {
  `perl -pi -e 's/blynk/blink/' $arg`;
  print "Blinking text is enabled in file(s) \"$arg\"\n";
} elsif ( $bt eq "-bd" ) {
  `perl -pi -e 's/blink/blynk/' $arg`;
  print "Blinking text is disabled in file(s) \"$arg\"\n";
}
Replies are listed 'Best First'.
RE: Disable animated GIFs and blinking text in Netscape
by japhy (Canon) on Sep 20, 2000 at 22:46 UTC
    Several suggestions:
    • The -s switch to Perl allows you to use simple options at the command-line:
      % perl -s -e 'print $A, $B' -- -A -B=hello 1hello
    • Don't call perl from perl unless you have a good reason to. If you want to emulate Perl's in-place editing, then do so.
    Here's my offering:
    #!/usr/bin/perl -spi use strict; use vars qw( $gif $blink ); my $files; BEGIN { unless ((defined $gif or defined $blink) and @ARGV) { (my $exec = $0) =~ s!.*/!!; exit warn "usage: $exec [ -gif=[1|0] ] [ -blink=[1|0] ] files...\n +"; } $files = "@ARGV"; } if (defined $gif) { if ($gif) { s/ANIMEXTZ1\.0/ANIMEXTS1.0/, s/NOTSCAPE2\.0/NETSCAPE2.0/ + } else { s/ANIMEXTS1\.0/ANIMEXTZ1.0/, s/NETSCAPE2\.0/NOTSCAPE2.0/ } } if (defined $blink) { if ($blink) { s/blynk/blink/ } else { s/blink/blynk/ } } END { printf "Animated GIFs are %sabled in $files\n", ("dis","en")[$gif] if defined $gif; printf "Blinking text is %sabled in $files\n", ("dis","en")[$blink] if defined $blink; }
    I'll comment on (or explain) the code as requested.

    $_="goto+F.print+chop;\n=yhpaj";F1:eval

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: sourcecode [id://33368]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-03-29 07:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found