Quick and dirty Win32 web browser ON/OFF proxy toggle, tested with FireFox and IE6. Useful when switching between networks at work and home (for me, 5/7 days). As always, back up important files before risking them.
use strict; use warnings; my $proxy_on='user_pref("network.proxy.type", 1);'; my $prefs_js='C:/Documents and Settings/EdwardG/Application Data/Phoen +ix/Profiles/default/7h4tw1oc.slt/prefs.js'; open my $p,'<',$prefs_js or die $!; my @prefs = <$p>; close $p; my @prefs_minus_proxy = grep !/\Q$proxy_on\E/, @prefs; my $proxy_was_off = ($#prefs == $#prefs_minus_proxy); open $p,'>',$prefs_js or die $!; print $p @prefs_minus_proxy; print $p $proxy_on if $proxy_was_off; close $p; # Internet Explorer 6 my %regHash; use Win32::TieRegistry ( TiedHash => \%regHash ); # thanks tye! $regHash{"CUser\\Software\\Microsoft\\Windows\\CurrentVersion\\Interne +t Settings\\ProxyEnable"} =[ $proxy_was_off ? "0x0001" : "0x0000", "REG_DWORD" ]; $|=1; print "Proxy is now ", $proxy_was_off ? 'ON' : 'OFF';

Replies are listed 'Best First'.
Re: Toggle browser proxy on and off
by greenFox (Vicar) on May 20, 2004 at 03:50 UTC
    I use the SwitchProxy extension under Firefox, it's great if you use multiple proxy servers and one of it's options is "none".

    --
    Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho

Re: Toggle browser proxy on and off
by der_herr_wahl (Initiate) on Oct 10, 2004 at 18:04 UTC
    hi, i wrote a similar script some time ago (to switch konqueror and firefox settings). correct me if this is just a linux thing, but in the case of firefox, i think you should rather switch proxies in the "user.js" file, because it wont be overwritten if you already have an instance of firefox running. (as written in the prefs.js file itself)
    greetings
    matthias