roachfiend.com

  • firefox extensions
  • tutorials
  • faq
  • December 2, 2005

    Update your extensions’ maxVersion with perl

    Filed under: tutorials — Eric @ 7:48 pm

    Whenever a new version of Firefox comes out, there are invariably a few extensions that won’t work with it. Not because the extension’s functionality is no longer suited, but because of a value that is set too low- the maxVersion. That tells Firefox that the extension is only compatible with a certain version of Firefox. You can update the extension by opening it up, and changing the maxVersion to the current Firefox version, or even higher. The easiest way to do this is to use a perl script to do it for you.

    If you don’t have perl installed on your Windows machine, it’s a free download here: ActivePerl

    It’s an easy setup, just click a few buttons, then you’re done. Then copy and paste the following into a new file and call it maxversion-updater.pl or anything, really, as long as you have the `pl` extension.

    The easiest way to find where your profile folder is this:

    Start > Run > %appdata%\Mozilla\Firefox\Profiles

    Copy the 8 digits before the `.folder` and paste them in the script below.

    - – -

    #!/usr/bin/perl

    use File::Find;
    use strict;

    # Firefox extension update script, written by Eric Hamiter
    #
    # This script will attempt to update extensions used on
    # earlier builds of Firefox by changing the maxVersion fields.
    # It will probably work, but might accidentally set
    # your house on fire. I don’t accept responsibility for what
    # might happen, so use at your own risk.
    #
    # Modify the following lines to point the variable to your
    # Firefox profile directory and specify the new Firefox version.

    my $default_folder=”xxxxxxxx.default”;
    my $new_version=”1.5″;

    # The rest of the script requires no modification.

    my $max=”em:maxVersion”;
    my $def=”$ENV{‘APPDATA’}\\Mozilla\\Firefox\\Profiles\\$default_folder”;
    my $directory=”$def\\extensions”;

    find (\&change, $directory);

    sub change
    {
    my @newMax;
    my $oldMax;

    if ( $File::Find::name =~ /\.rdf$/ ) {

    open (FILE, $File::Find::name ) or
    die “Cannot open file: $!”;

    print “\n” . $File::Find::name . “\n”;
    while ( $oldMax = ) {
    $oldMax =~ s/<$max>.*$new_version $oldMax =~ s/$max=".*"/$max="$new_version"/i;
    push(@newMax, $oldMax);
    }
    close FILE;

    open ( OUTFILE, ">$File::Find::name” ) or
    die “Cannot open file: $!”;

    print ( OUTFILE @newMax );
    close ( OUTFILE );

    undef( @newMax );
    }
    }

    - – -


    8 Responses to “Update your extensions’ maxVersion with perl”

    1. Will Says:

      Thanks to CrazyCoder:

      Well this is even easier:

      use File::Find;
      use strict;

      my $path = $ARGV[0]?$ARGV[0]:”./”;
      my $newver = $ARGV[1]?$ARGV[1]:”1.6+”;

      my @files = ();
      print “Listing files… please wait…\n”;
      find sub{ push(@files, $File::Find::name) if $File::Find::name=~/install.rdf/i}, $path;

      foreach my $file (@files) {
      print “$file\n”;
      open(IN, $file);
      my @all = ;
      close(IN);

      my $repmode = 0;
      open(OUT, “>$file”);
      foreach my $line (@all) {
      chomp($line);
      if($line =~ qw%{ec8030f7-c20a-464f-9b0e-13a3a9e97384}% ||
      $line =~ qw%{ec8030f7-c20a-464f-9b0e-13a3a9e97384}% ||
      $line =~ qw%em:id=”{ec8030f7-c20a-464f-9b0e-13a3a9e97384}%) {
      $repmode = 1;
      }

      if($repmode &&
      ($line =~ s%.*?%$newver% ||
      $line =~ s%.*?%$newver% ||
      $line =~ s%em:maxVersion=”.*?”%em:maxVersion=”$newver”%)) {

      print $line . “\n”;
      $repmode = 0;
      }
      print OUT $line . “\n”;
      }
      close(OUT);
      }

      Or even better. ;)

      http://swnet.spb.ru/files/repver.zip

      I used Perl Dev Kit to make an executable from my script which should run on any platform.

      hehe

    2. Bite my bytes Says:

      Firefox Extensions

    3. AG Build 3.20050706 Says:

      Or you could use an existing extension called Mr. Tech Local Install.

      Here’s the link:
      https://addons.mozilla.org/extensions/moreinfo.php?id=421

      Here’s my write up:
      http://blogplus1.someguysserver.com/archives/117-Crucial-Firefox-Extension-Mr-Tech-Local-Install.html

    4. Richard Froggatt Says:

      I wish I would have seen this a couple of days ago. If you run across an extension that is not compatible with FF 1.5 can it be tweaked and then installed?

      Thanks for the tutorial.

    5. Will Says:

      When you download a .xpi file, that is an extension it asks if you wish to overidge requried version and install. You just check that option and install like normal. :)

    6. J Fizz Says:

      Hi, I followed the instructions above, even got a little black box to come up and it looked like it was doing something, but still none of my old extensions are working with FF 1.5.

      I’d appreciate any help,

      Thanks!

    7. J Fizz Says:

      Sorry to re-post, I was able to use Mr. Tech Local Install to update. Thanks to the Roach!

    8. Amit Srivastava Says:

      great tutorial buddy :)

    Leave a Reply

    You must be logged in to post a comment.